Kirk McElhearn recently blogged about using Spotlight to find Smart Folders. His idea, which is a good one, was to use the Comments field to add a unique identifier to saved searches -- "RobSearchFolder" or whatever; just make sure it's unique to your saved searches. Then use Spotlight to search for that unique string, and you'll see all your saved searches in one spot, regardless of where you might have saved them (you can get the same effect with a folder in the Sidebar, but really, that's not the point of this hint).
Kirk's entry got me to thinking about better ways to use the comment field in Spotlight, so I talked Doug Adams (of Doug's AppleScripts for iTunes fame) into writing an AppleScript for me. The essence of the AppleScript is that it will automatically tag any item added to a designated folder with a Spotlight comment of your choice. If the item already has Spotlight comments, the script will append them, so you won't lose any existing comments. This can help automate the process of making some of your content very easy to locate with Spotlight. Here are a few ways you might use this script:
First, open Script Editor in /Applications/AppleScript, and paste in the Spotlight Comments script. Modify the flag line, replacing MySpotlightComment with the unique value you'd like to use. Make sure it's something that Spotlight won't find in any other files. Now save the script in your user's Library/Scripts/Folder Action Scripts folder -- this is key, for the script won't work unless it's saved here. You may have to create the Folder Action Scripts folder if it doesn't yet exist. Give the script a meaningful name for the role it will be playing. "TagSavedSearches," for example, if you're using it for your Saved Searches folder.
Next, you need to make sure you've got Folder Actions enabled. Select any folder, control-click on it, and choose Enable Folder Actions from the pop-up menu. If you want to use this hint for the Finder's Smart Folders, first make sure you've created a few saved searches (so the following folder will already exist). Then navigate to your user's Library/Saved Searches folder, and control-click on it. Select Attach a Folder Action from the pop-up menu, then navigate to the Folder Action Scripts folder in which you saved the script. Click on the script's name, then click Choose. That's it, you're done.
From now on, any time you save a Finder search, it will automatically be tagged with the string you entered into the script (note that existing saved searches are not tagged; you'll have to add the tag yourself, or delete and recreate the searches). You'll see a dialog pop-up, letting you know the search has been tagged. You can disable this by commenting out (add -- at the front) the line that begins display dialog....
To use the script on other folders, just duplicate it, rename it, then edit it to change the unique comment value. Control-click on the folder you wish to 'tag,' and then attach the newly-duplicated script.
Thanks to both Kirk for the idea and to Doug for all the hard work -- I've already got this script working on my Saved Searches folder, along with a couple job-related folders. It's a big timesaver...
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050614071122965