1

If I open up Spotlight, I can use metadata attributes such as kind:pdf and date:today to refine my search.

I'm curious if there's a way to list all of these attributes that I can use with this syntax (attribute:value)

  • 1
    mdimport -A (command line) lists available attributes. man mdimport for more info and related commands. – mtklr Oct 8 '17 at 23:39
1

Good question. There is a page on the Apple Developer site that goes into details of Spotlight metadata attributes. Though it's developer focussed I think you'd be able to draw inferences from the attribute keys listed there, e.g.

  • kMDItemKind
    Description of the kind of item this file represents.
  • kMDItemAttributeChangeDate
    Date and time of the last change made to a metadata attribute
  • kMDItemContentCreationDate
    The date and time that the content was created.
  • kMDItemContentModificationDate
    Date and time when the content of this item was modified.

The nice thing about this list is, that it's quite exhaustive, but it also means that developers would have needed to build this into their apps, so that Spotlight could accurately index the content.

On this list you also find more "obscure" (or lesser known) attributes, such as

  • kMDItemCreator
    Name of the application used to create the document content. For example, "Pages" or "Keynote".
  • kMDItemKeywords
    Keywords associated with this file. For example, "Birthday", "Important", etc.
  • kMDItemNumberOfPages
    Number of pages in the document.
  • kMDItemPageHeight
    Height of the document page, in points (72 points per inch). For PDF files this indicates the height of the first page only.

If you're interested, there's also an oldish article over at the Superuser blog that gets into some of the details of using Spotlight including commands you can use from Terminal. There's a link in the article (about ⅔ down) pointing to a full list of attributes Spotlight keeps for you. That link is dead, but I've dug out a copy from the Wayback Machine for you. It's similar to the page on the Apple Developer site I provided before.

I've tried some of these examples out and it turns out that the command line would allow you to use the listed attributes, such as kMDItemLastUsedDate. It also seems to allow for a much finer use, such as Boolean use and number ranges like ">=10".

I've subsequently successfully used TextContent:"something", Country:AU (for Australian content), date>20/1/2017 (that's 20 Jan 2017 in my lingo and filters everything after that date) and author:Alex (e.g. returns documents and emails created by me) in Spotlight's GUI. This article on Spotlight tips for El Capitan & Yosemite (slide 10) mainly mentions the kind: filter, though they also name the above date and author.

What you can use very much depends on what developers of applications that save documents to disk have implemented using the metadata importer to provide Spotlight support.

You must log in to answer this question.

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