Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to search a specific type of file using Spotlight? I remember there was a special command or something that I had to put in front of the search phrase but I cannot remember it now.

For example, if I want to search only PDFs for a particular phrase in Spotlight, what would I do?

share|improve this question
up vote 28 down vote accepted

Search by Kind One of the most useful ways to narrow down a search is by using the kind: keyword. This allows you to restrict your list of results to a certain file format. For instance, if you type time machine kind:pdf, Spotlight will pull up only PDF files containing the words "time" and "machine". You can also limit your search to e-mail messages, music files, System Preferences, applications, and more.

While the original Spotlight recognized only a limited number of file types, the Leopard version can look for files created by specific applications, as well as certain file formats. Searching for kind:mp3 or kind:tiff will find files in one of those formats, and searching for kind:pages or kind:powerpoint will show only documents created in one of those programs. For a list of useful keywords, see “My Kind of Keyword.” But remember, for the keywords to work, you must have the appropriate categories enabled in Spotlight’s preferences.

you can get more info here or here.

alt text

share|improve this answer
Ah, yes! This was the command that I needed! Thank you very much. :) – JFW Aug 27 '10 at 8:34
This is so AWESOME. I didn't know you could do this. Thanks very much. – Henry Sep 11 '10 at 22:08
You should be more clear that this answer was copied and pasted from – Dori Sep 13 '10 at 8:14

It's already been answered, but here's my 2 cents.

Via Bash through the terminal

find ~ -type f -name '*pdf' or find ~ -iname '*pdf'

(or, if you want to ignore error messages, find ~ -type f -name '*pdf' 2>/dev/null)

or you can use this to search for a string in a file:

find ~ -iname '*txt' | xargs grep 'string you want'

This may not return anything on a pdf, but it will work on most other file types (text, php, py, html, etc).

share|improve this answer
it's like grep :) – Am1rr3zA Sep 11 '10 at 22:57
It helps to add /dev/null: find / -iname '*mp4' 2>/dev/null find / -iname '*mp3' 2>/dev/null – cokedude Mar 30 at 6:14

It's not possible via spotlight (at least on Yosemite). You can only use finder.

  1. Start a search with Command+F.
  2. Click on the '+' icon on the far side of the taskbar
  3. Select the type from the 'kind' pull-down menu. Select 'other' and then find 'File extension'

Enter your desired file extension and hit enter

share|improve this answer
Great answer! I never knew this till today! – Paul Wagland Apr 24 '15 at 19:34
this works really well and is fast. – BryanK Apr 30 '15 at 19:31
  1. Open a Find Window (cmd-f) or do a spotlight search and select "show all"
  2. Hit the little "+" icon (to the right of the 'save' button)
  3. Select File Type as a search criteria and select the correct one.
  4. Rerun the search.

(Disclaimer, I'm not on a Mac right now :( so my exact instructions might be a little off).

share|improve this answer
mdimport -A 

will give you every possible attribute available on your system

kMDItemKind is the attribute for files, but perhaps the above will suggest a better attribute to search on.


mdfind "kMDItemKind == 'whatever'"

The syntax might make you shout out in disgust. I can personally attest that it ruins zsh completion. Still, Spotlight ( that's what this is ) indexes your stuff all the time anyway, and it's fast. Might as well use it. YMMV

share|improve this answer

The question "How to use Regex with spotlight" is marked as a duplicate of this for some reason, so I thought I would share how to do wildcard searching.

You can do wildcard searching in the Finder using a Kind of "Raw Query" with the kMDItemDisplayName attribute: Raw Query example

Raw Queries are essentially what you use with the mdfind command. I have more details on Raw Queries and using them in the GUI at

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.