« 9 Types of Users: Frying Pan/Fire Tactician | Main | 9 Types of Users: Shaman »
January 05, 2006
Finder labels
I happen to use LabelsX but even without it, it can be handy to use labels in the Finder. The problem is that often the labels need to be applied regularly to be useful. In my case, I like to tag work-related documents as to their recency and type - that makes it easy to find the right file in small dialogue boxes.
In keep a whole bunch of documents in a single folder tree. I want to see current (< 30 days since last changed), archival (no longer current), links (where the file is not locally stored) and Microsoft Office backup files (because I can delete them). To do all this, I have a shell script that runs once a day. It is not very efficient because it runs multiple find
s over the same directory...
#!/bin/sh
function findfile()
{
find . \\( -name \"200[56]*\" \\
-or -name \"Backup*\" \\
-or -name \"*.doc\" -or \\
-name \"*.xls\" \\) \\( -type f \\
-or -type d \\) $2 -exec osascript \\
-e \"$SCRIPT $1^M end tell\" \\; 2>&1 >/dev/null
}
DIR=/path/to/directory
SCRIPT=\"tell application \\\"Finder\\\"
set fileName to posix file \\\"$DIR/{}\\\" as file
set the label index of item fileName to \"
cd $DIR
# Set all documents to \'Red\'
findfile 2
# Change backup documents to \'Purple\'
findfile 3 \"-regex .*/B.*\"
# Change older documents to \'Blue\'
findfile 5 \"-mtime +30\"
# Change empty (link) documents to \'Green\'
findfile 6 \"-empty\"
Note that the script is partially in the $SCRIPT
variable and partly in the shell function. Next week we will convert this into a perl script and make it faster (and more efficient)....
Posted by Ozguru at January 5, 2006 06:00 AM
Comments
I have nothing to say about this technical gee-whiz. I just wanted to say that I am going to peskie@gmail and see what it gets me.
Posted by: old horsetail snake at January 7, 2006 10:29 AM
That would reach (on of) my brother(s) via email. He used to have his own blog (see Peskie) in the sidebar.
Posted by: Ozguru at January 16, 2006 05:51 AM