Be Ultra-Accurate with Spotlight – Mac Kung Fu, 2nd Edition

Tip 182Be Ultra-Accurate with Spotlight

Spotlight is precise in providing files that match your search query, but you can also force it to be even more specific, returning only certain types of files in the results, for example, or only those files with certain characteristics.

Searching for Types of Files

To force Spotlight to search only for a particular type of file that matches your search term, such as images, type kind: and then the type of file you’re looking for. For example, to search only for audio files matching the word bieber, I’d type the following:

 
kind:music bieber

To search for documents matching the word report, type the following:

 
kind:documents report

You can see a full list of words that can be used in the following table. Remember that Finder includes a Spotlight search field at the top right of each file browser window, and this technique works there too.

If specified without anything following, Spotlight will return a list of every particular file type on your system.

kind:modifier

Description

kind:alias

Returns only file aliases.

kind:app

Returns only applications within Spotlight results.

kind:bookmark

Returns only Safari bookmarks (not those of other browsers you may have installed) and also entries within your browsing history.

kind:contact

Returns entries from the Contacts application.

kind:document

Returns documents, although this is a broad term applying to any file that is a container for text and not just office documents. You can use kind:word to return only Microsoft Word documents and kind:pages to return only iWork Pages documents.

kind:email

Returns only mail messages (kind:mail can also be used).

kind:event

Returns calendar entries from the Calendar app.

kind:exe

Returns only developer files (files generated by Xcode, for example).

kind:folder

Returns only folders.

kind:font

Returns only fonts installed on the system.

kind:movies

Returns only movie files, as mov or avi files, or downloaded iTunes movies; to return only QuickTime movies, use kind:quicktime.

kind:music

Returns only audio files, such as MP3s or downloaded iTunes songs (kind:audio can also be used).

kind:pdf

Returns only PDF files.

kind:pic

Returns only images, such as JPEG or TIFF files (“kind:image” can also be used)—use kind:jpeg to return only JPEG images kind:tif to return only TIFF images, and use kind:gif to return only GIF images (sadly, kind:png will not return PNG files!).

kind:preferences

Returns only System Preferences configuration tools.

kind:presentation

Returns only presentations (that is, Microsoft PowerPoint or iWork KeyNote files)—use kind:powerpoint to return only PowerPoint files and kind:keynote to return only KeyNote files.

kind:spreadsheet

Returns only spreadsheets (that is, Microsoft Excel or iWork Numbers files)—use kind:excel to return only Excel files and kind:numbers to return only iWork Numbers files.

Searching via Label

You can also use label: to search for color-labeled files (that is, files that you’ve applied a color to by right-clicking them and selecting a color under the Label heading—see Tip 189, Manage Projects with Colors). label: needs to be followed by the name of the color. For example, to use Spotlight to search for files colored red, you’d type label:red. The choices are red, orange, yellow, green, blue, purple, and gray.

Searching by Author

Using the author: keyword, you can specify the author of the document—the person who sent the email, for example, or the person listed within a Microsoft Office document as the author. Enclose the name in quotes if you specify more than one word: author:"keir thomas" will return documents and emails created by Keir Thomas, for example.

Limiting Spotlight Results to Particular Dates

You can have Spotlight return results only for those files created or modified on a particular day. To do so, type date: followed by today or yesterday in the search field to see only those files created or modified today or yesterday. You can also specify a date: date:10/3/2011 will return files created or modified on October 3, 20, for example. (Those outside of the United States should use native date formats instead: date:3/10/2011, for example.)

You can also specify date ranges: date:8/1/2011-8/31/2011 will return files created or modified in the month of August 20, for example.

Specifying Words NOT to Search For

Let’s say you’re using the Spotlight search tool to find emails mentioning getting an iPad as a present for your friend John. You perform a search using the keywords ipad and john and find that, along with the emails you’re looking for, there are also emails from Frank discussing how cool the iPad is. You don’t want to see those emails.

To stop a particular word from appearing in Spotlight’s results, you can add a minus before it.

Using the previous example, the following would return results that specifically don’t include any mention of Frank:

 
john ipad -frank

Another way to refine searches is to use AND, OR, and NOT (these are known as Boolean operators). For example, to search for a message containing either the word ipad or tablet, you could type the following:

 
ipad AND tablet

It’s important that AND, OR, and NOT are typed in uppercase, because otherwise Spotlight will consider them part of the search string.