Cut through the Clutter

Smart folders disguise Tiger’s convenient and dynamic Spotlight searches as good old-fashioned folders. You can use a smart folder to keep track of almost anything—from all the documents you’ve opened this week to every Excel file you’ve highlighted with a red label.

Even better, smart folders give you access to hidden metadata and advanced Spotlight features, so you can find files that would elude conventional searches. Learn to set up a search string just right, and smart folders can reduce your need to organize.

Find what you seek

To create a smart folder, choose File: Find (or press Command-F). In the New Search window that appears, you’ll see buttons that let you choose where to search, along with pop-up menus for narrowing the search criteria. Save any search as a smart folder by clicking on the Save button. Alternatively, choose File: New Smart Folder (or press Command-option-N), and the New Smart Folder window appears.

By default, the Finder saves smart folders in / your user folder /Library/Saved Searches. But you can save them on the desktop or in your user folder and then move them manually. Whenever you open a smart folder, it will display the current results of your search; the files themselves remain in their original locations.

The Perfect Query How useful your smart folders will be depends on how well you put together your search strings. Type text into the toolbar’s search field, and Spotlight returns all items that include that text in their file name or content (see “Focus the Spotlight”). For example, if you’d like to create a smart folder that keeps track of every file that mentions your favorite philosopher, you can use one search term, such as Hume. Because the search is case-insensitive and looks for any word begin-ning with the term you entered, it will also find the anatomy paper in which you mentioned the humerus.

If you enter more than one word, Spotlight treats your search as an AND search—it finds items containing all the words (or, to be precise, all the words beginning with the strings you entered) in the title or contents. You can also enclose phrases in quotation marks. Type

"AppleScript Studio"
to find items with that entire phrase in their title or other metadata (Spotlight can’t find complete phrases in an item’s content).

The Right Place The New Search (or New Smart Folder) window can limit a search to specific locations. Click on one of the buttons in the header (Servers, Computer, Home, and so on) to search only in that location. To limit your search to one or more particular folders or volumes, click on Others, click on the plus-sign (+) button at the bottom of the window, and then add the locations.

Search Attribute Aptitude If you’re looking for something very specific, check out the search-attribute pop-up menus. These offer you much more control. Pick and choose from the pop-up menus to create additional conditions for your search—for example, Kind Is Music, Last Modified Is Within The Last 2 Weeks, or Size Is Less Than 3 MB.

Smart Ideas Here are two more ideas:

• Create a smart folder that keeps track of all the files you’ve been working on recently. Set the Kind attribute to Documents and add a second condition: Last Opened Since Yesterday.

• If you mark important files with the Finder’s color labels, use the Color Label attribute to create a smart folder that displays all the files marked with, say, a red label, regardless of their location.

Explore the other side

Simple smart folders are powerful, but you can go further still. Choose Other from one of the pop-up attribute menus, and a window appears in which you can choose from more than 100 additional attributes. If you expect to use an attribute—Title, for example—frequently, select the Add To Favorites option to put it directly in the pop-up menus.

You’ll find detailed information about digital photographs and cameras—such as aperture, exposure time, device make and model, and whether the flash was used. The list also includes ratings (for photos in iPhoto or songs in iTunes), author and creator names, and dozens of other options.

One attribute on the Other list deserves special mention: Spotlight Comment. You can add comments to any file by selecting it in the Finder, choosing File: Get Info, and typing in the Spotlight Comments field at the top of the Info window. Search these comments using the Spotlight Comment attribute.

Smart Ideas You can construct some fantastic smart folders using attributes in the Other list.

• To keep track of project files in many locations and of many types, give them all the same Spotlight comment. Pick a unique string, such as JoesGreatNovel . (The prefab Automator workflow Batch Apply Spotlight Keywords can apply your keyword fast.) Then create a smart folder with the search condition Spotlight Comment Contains JoesGreatNovel (or whatever string you used). All the project’s files will magically appear in the folder.

• Want a quick way to find all the nighttime shots you took with your Canon camera? Create a smart folder with these three conditions: Device Make Contains Canon, Flash Yes, and Rating Greater Than 3.

• If you’re trying to clean up your iTunes library, create a smart folder that displays particular musical categories: for example, all jazz tracks recorded at a low bit rate. Use these conditions: Kind Music; Musical Genre Jazz; and Audio Bit Rate Less Than 160.

Learn Spotlight’s language

Once you get excited about smart folders, you might start to chafe at their restrictions. The Other list is long, but it doesn’t contain every type of metadata Spotlight can search for. The Find window itself also imposes some restrictions. For instance, using only the pop-up menus, you can’t do any OR searches—say, look for JPEG or PDF files. Worst of all, unlike the searches you perform using the Spotlight menu, smart folders exclude Mail messages and Address Book contacts by default. (And unfortunately, Spotlight can’t search messages in most other e-mail programs.)

Luckily, you can overcome most of these limitations by using an obscure item on the Other list called Raw Query. Entering a raw query is like talking directly to Spotlight in its native language. In fact, every time you create a smart folder, the Finder translates your menu choices into a raw query, which you can see in the smart folder’s Get Info window.

Raw Queries Revealed Raw queries look different from regular Spotlight searches. Instead of plain English words, such as Name and Kind , they use odd terms such as kMDItemDisplayName and kMDItemKind . (The k stands for constant , by the way, and MD stands for metadata .) The way you construct queries, however, is straightforward. Enclose each expression, or search condition, in parentheses and use the proper symbols to separate your search terms.

For instance, to find either JPEG or PDF files, but no other file types, create a new smart folder, choose Other from the attribute pop-up menu, select Raw Query from the list, and click on OK. Then enter this raw query in the attribute’s text field:

(kMDItemKind == *JPEG*) || (kMDItemKind == *PDF*)
.

I used an asterisk (a wild-card character) before and after each file type because Spotlight might use a longer name, like PDF Document or Adobe PDF Document, and I want to catch all the variants.

Subtle Searching To make a search term case-insensitive, for example, enclose it in quotation marks and follow it immediately (no spaces) with the letter

c
(r aw queries are case-sensitive by default). You can also use
d
to ignore diacritical marks or
w
to specify that the term must be a whole word. For example, the search
kMDItemTextContents == "cafe"cd
would match cafe, Café, and café.

Smart Ideas Here are some ways you can use raw queries in your smart folders ( Click here to learn more):

• Use this query to display all five-star photos except those taken with your low-resolution Motorola camera phone:

(kMDItemContentTypeTree == 'public.image') && (kMDItemStarRating > 4) && (kMDItemAcquisitionMake != *Motorola*)
.

• Use this to find all Mail messages or Word documents containing the phrase Take Control (enclose the search phrase in single quotes, because it includes a space):

((kMDItemContentType == com.microsoft.word.doc) || (kMDItemContentType == com.apple.mail.emlx)) && (kMDItemTextContent == '*Take Control*')
.

[ Joe Kissell has written numerous e-books about Mac OS X software. ]

Focus the Spotlight The Smart Folder window displays Spotlight’s current search results and has controls for further narrowing the search. Enter your search string in the text field (A) , choose where to search (B) , and pick additional search attributes from the pop-up menus (C) . OS X automatically adds smart folders to the Finder’s sidebar for easy access.
1 2 Page 1
Shop Tech Products at Amazon