With the release of Mac OS X 10.5, Leopard, Apple has greatly improved its search technology, called Spotlight. Introduced with the previous version of Mac OS X (Tiger), Spotlight was both brilliant and stunted; brilliant because it can work so well in certain situations, but stunted because it was so limited. It didn’t offer Boolean searches (AND, NOT, OR), which meant all your searches were, like Google searches, based on every word you entered. So if you typed King and Lear, you’d find anything with both words, but not with King or Lear alone. And there was no way to find a file containing Kind and NOT Lear. All that’s changed.
Boolean searches, however, are just the tip of the iceberg. Tiger had a couple of operators you could use with keywords, that most people didn’t know about. They were the kind: and date: keywords. You could type, say, kind:pdf to find PDF files; or kind:music to narrow a spotlight search down to music files. And you could use date:today to find files modified today, and date:tomorrow to find appointments scheduled for tomorrow. (You can use both these keywords in the Spotlight menu, or in the Finder’s Search field.)These two keywords still exist in Leopard, but are greatly expanded. Let me begin with the date: keyword, since it’s the simpler one. To start with, Apple has added operators that you can use with this keyword: they are >, <, and -.
Here are some examples:
date:>1/1/07 will find any file modified after January 1, 2007. (The dates you enter must correspond to the short date format you have set in your International preferences.)
date:<12/31/07 will find any file modified before December 31, 2007.
date:1/1/07-12/31/07 will find files modified between those two dates.
But things get interesting when you look at the kind: keyword. Apple has expanded this to dozens of new kinds, and made it potentially limitless. There is no list of kinds, but you can get an idea by doing the following. In the Finder, type the letter “a” in the search field. Choose List View (click the List view icon, or press Command-2). Then click the Kind column to sort by kind in alphabetical order. You’ll see a wide range of kinds: from Alias and Application to ZIP Archive, by way of MP3 Audio Files, Folders, JPEG Images and much more. Now try a Spotlight search, either from the Spotlight menu or the Finder: type, say, kind:word, if you have Microsoft Word documents on your Mac; if not, try kind:text. The former will show you all your word documents, and the latter will show you all your text files, at least those created by TextEdit and some other applications.
This is especially useful when tracking down files you made with specific applications. For example, I’m writing this article in BBEdit; I can search for all BBEdit files by typing kind:bb (you don’t always need to type out the entire kind to get hits; two or three letters may be enough).
Well, you may think that’s powerful, but you haven’t seen anything yet. In addition to these expanded operators, Spotlight now has a limitless set of other operators. Not only are there kind: and date: keywords, but there are dozens of new keywords. None of this is documented yet, but you can get a glimpse of what’s available by selecting the Other attribute in the Finder’s search bar, or by checking the following file:
The former gives you names and explanations, and the latter shows you exactly how to type the operators. For example, to use Audio Bit Rate, you’ll see in the latter file that you have to type either audiobitrate: or bitrate:.
Here are some examples of the new operators:
Find a file by searching for the person who created it (in programs that store this information) by typing author:. For example, I’ll find files I’ve created with author:kirk. For now, the only programs I have that come up are Word, Pages, Mail and iChat (chat logs). There are also some PDF’s I’ve created from Word or Pages files. (You can also use from:, with: or by: to find the same information.)
Find files created using the AAC codec with codec:aac. This finds both music and video files.
Find files with comments using the comment: operator. This applies to comments made to iTunes files as to Spotlight comments added in the Finder; other programs may also support this.
Find files with an audio bit rate of 32 kpbs by typing audiobitrate:32, or bitrate:32.
Find music files where Bach is listed as composer: composer:bach.
Find pictures taken at an ISO speed of 400 by typing iso:400; find photos taken at an ISO speed higher than that by typing iso:>400.
I’ll stop here, but you can see that the possibilities are quite extensive. In addition, third party programs can add their own attributes that can be searched. One way to find what they can do is to take a file and run the mdls command in it in Terminal (mdls <filename>). This will display all the file’s metadata, and will allow you to discover which attributes it is using. You’ll also see this information in the Finder, when you choose the Other search attribute as explained above.
As yet, Apple hasn’t documented this, so let’s hope they do so soon with a complete list containing explanations. (For some of these operators it’s not clear exactly how to use them; however, if you have files that they can find, some trial and error should help you discover the answer.) These operators are likely not something you’ll use daily, but when you’re trying to find that lost file on your Mac, or simply trying to sort a group of files, will come in handy.