# Commonly used Spotlight attributes * kMDItemFSName: basename. * kMDItemFSSize: size in bytes. * kMDItemDisplayName: display name. * kMDItemContentType: UTI. * kMDItemContentTypeTree: UTI and parent UTIs. * kMDItemKind: a localized name for the content type. * kMDItemFSContentChangeDate: modification time. * kMDItemFSCreationDate: creation time. * kMDItemLastUsedDate: date last opened. * kMDItemDateAdded: date added. * kMDItemFinderComment: Spotlight comment. * kMDItemTextContent: plain text content of for example text, HTML, or PDF files. * kMDItemDurationSeconds: for example the duration of an audio or video file. * kMDItemTitle: for example the title of a webloc, PDF, or MP3 file. * kMDItemURL: for example the URL of a webloc file. * kMDItemWhereFroms: the URL or URLs that a file was downloaded from. * kMDItemUserTags: tags in 10.9 and later. * kMDItemAuthors: for example the artist of an MP3 file.
# kMDItemPath There is a kMDItemPath attribute, but it can't be used in queries. You can grep the output of mdfind though:
$ pp() { path="/${1%/*}/"; mdfind "name:${1##*/}" | grep -i "${path//\//.*\/}"; } $ time pp desk/ante /Library/Desktop Pictures/Antelope Canyon.jpg 0.365
Matching kMDItemFSName is often a lot slower:
$ time mdfind "kMDItemFSName=\"ante.*\"c" | grep -i '/desk.*/' /Library/Desktop Pictures/Antelope Canyon.jpg 10.232