APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2005/05/10 Smart Folders (Mac OS X)

Mac's Spotlight has the ability to create "Smart Folders". If you click "Save" after doing a Spotlight search, you'll be creating a plist file which by default will be created in ~/Library/Saved Searches. It has a "savedSearch" extension, and contains the necessary information about your search:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">
	<string>(* = "fogpr1*"wcd || kMDItemTextContent =
	"fogpr1*"cd) && (kMDItemContentType != com.apple.mail.emlx)
	&& (kMDItemContentType != public.vcard)</string>

This is a "live" folder. If you have it open in Finder, and are creating files in Terminal or anywhere else that will match the criteria, those files will instantly appear in your view.

Note that the conditional string is much more complex than anything you can type in Spotlight itself. You can use boolean logic with the command line "mdfind", and have more control with the View Options of a Spotlight search (especially be selecting "Raw Query"), but you could also manually edit this plist to get exactly what you want.

I haven't yet thought of something I really need Smart Folders for, but the idea does tantalize me. I could set up a smart folder for each customer and thus automatically track any reference in any document, no matter where I created it. I'm sure other uses will come to mind. As GetInfo now includes "SpotLight Comments" where you can add searchable metadata (it's "kMDItemFinderComment" if you are hand-rolling searches), this could get quite interesting. For example, a directory (Folder in Mac-speak) has no particular connection with the type of data you intend to store in it, but you can tag it with anything you like with Spotlight comments.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Smart Folders (Mac OS X)

Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Tony Lawrence

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

The psychological profiling [of a programmer] is mostly the ability to shift levels of abstraction, from low level to high level. To see something in the small and to see something in the large. (Donald Knuth)

This post tagged: