10

I'm used to using various flags to modify the results of Google searches, to only show results from a particular site, or only certain kinds of files.

For example you can restrict Spotlight searches to only look for pdf files like this example, when I'm looking for a pdf cheatsheet for using YUI's grid system css framework on my computer.

YUI grid kind:pdf

I'd be amazed if Apple's Spotlight didn't have loads of other handy flags to fine tune a search in the same way - what tricks do you use, or where do you look to find more tips to improve your Spotlight-fu?

2 Answers 2

13

Spotlight menu and Finder

  • name:filename
  • kind:kindle (kind:mobi and *.mobi cannot be used)
  • kind:image
  • date:today (date:week and date:month don't work)
  • date:12/31/11 (other formats like date:2011-12-31 don't work)
  • date:12/1/11-12/31/11
  • kind:mp3 AND bitrate:<192000

Common metadata attribute keys

mdls -name $attribute $file shows the value of a single attribute and mdls $file lists all attributes.

  • kMDItemContentType: the uniform type identifier like public.plain-text
  • kMDItemContentTypeTree: the UTI and its parent UTIs
  • kMDItemDisplayName: the name of a file without an extension if its extension is set to be hidden
  • kMDItemDurationSeconds: for example the duration of audio or video files
  • kMDItemFinderComment: the Spotlight comment that can be set in Finder's information windows
  • kMDItemFSContentChangeDate: modification date
  • kMDItemFSCreationDate: creation date
  • kMDItemFSInvisible: the visibility of a file
  • kMDItemFSName: the name of a file with a filename extension
  • kMDItemFSSize: the size of a file in bytes
  • kMDItemKind: a kind description like HTML document
  • kMDItemLastUsedDate: date last opened
  • kMDItemNumberOfPages: for example the number of pages in a PDF file
  • kMDItemPageWidth: for example the width of a PDF document in points
  • kMDItemPath: the full path of a file
  • kMDItemTextContent: contents of the file
  • kMDItemTitle: for example the title of a PDF document or a website
  • kMDItemURL: for example the URL of a webloc file
  • kMDItemWhereFroms: a URL a file was downloaded from

mdfind query expressions

  • mdfind . -onlyin ~/Pictures
  • mdfind 'kMDItemFSContentChangeDate == $time.this_week(-1)'
  • mdfind 'kMDItemTextContent == "*expose*"cd' (ignore case and diacritics)
  • mdfind 'kMDItemFSSize >= 5000 && kMDItemFSSize <= 5005)'
  • mdfind 'kMDItemFSContentChangeDate >= $time.iso(2012-04-13T13:44Z)'
  • mdfind 'kMDItemFSCreationDate >= $time.now(-3600)'
  • mdfind 'kMDItemKind == "*movie" && kMDItemPixelHeight >= 720'
2
4

There's a whole article regarding this subject here. In short:

  • you use boolean operators, such as AND, OR, NOT
  • applying quotation marks will search for exactly the phrase you want
  • using name: keyword will only search file names
  • author: keyword allows you to search files by file author (Spotlight will find only files produced by programs that save this attribute—Mail, iChat, Word, Excel, Pages, Numbers, and a few others)
  • you can use date:today, created: date and modified: date to search for files by a particular date
  • you can refine your search to only find certain file types using kind: filetype (the article I linked to contains all the possible file types you might need)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .