0

I am looking for a very good documentation or tool, that help's me to make better searches in spotlight.I have found some descriptions like: "https://developer.apple.com/library/archive/documentation/CoreServices/Reference/MetadataAttributesRef/Reference/CommonAttrs.html#//apple_ref/doc/uid/TP40001694-SW1", there I can find e.g. kMDItemKind, but what is possible to define as Kind ?

I know in I can define a search like "kind:folder", but what's possible behind kind instead of folder, how can I find out what I am able to search for ? "kind:" stands here as a example, but there are much more keywords, but I want to know what are the possible values for this keywords.

Either a documentation/manual/reference about the keywords or a tool, that evaluates the possible values out of my spotlight database.

2
  • 1
    "I am looking for a very good documentation or tool, that help's me to make better searches in spotlight." There is list of 'kinds' one can use in Spotlight and Finder: Narrow your search results on Mac > Search by the type of items + some other keywords one can use. Jun 11, 2021 at 11:38
  • Whilst you are asking about improving your Spotlight skills with regard to Kind, also consider using HoudahSpot houdah.com/houdahSpot which is a more powerful (and generally better) front end to the Spotlight index.
    – Gilby
    Jun 12, 2021 at 5:30

2 Answers 2

0

When searching using Finder, the kind: tag is populated from multiple fields in the Spotlight index. As well as kMDItemKind field it may use elements of the multivalued field kMDItemContentTypeTree where they are appropriate.

The complex (non-obvious) nature of the kind: search tag can be seen by a Finder search with kind:document. As well as files with 'document' somewhere in the kMDItemKind field, this finds files with other words in the kMDItemKind field. Just as an example, search results include some .gpx files (tracking logs) which have the text 'GPX File' in the kMDItemKind field. Finder/Spotlight is identifying these as documents based on the kMDItemContentTypeTree field which is:

kMDItemContentTypeTree = (
    "com.apple.dt.document.gpx",
    "public.xml",
    "public.text",
    "public.data",
    "public.item",
    "public.content"
)

The public.text indicates a file readable like a 'document'.

The above discussion is primarily to show that predicting exactly what will be returned with a kind: Finder search is not simple. Nevertheless the content of the kMDItemKind field is a key part of this. So there is some value in knowing what kind: values are available from kMDItemKind.

The list of kinds in kMDItemKind is only limited by your actual files and and how the Spotlight importers populate the field. Lets look at how to get a list of 'kinds':

Method 1:

We can inspect the spotlight metadata of every file and extract just the kMDItemKind attribute. That will list all the Kinds which will return results. The script I give here is extremely slow, so:

  • Only run it over important directories (not everything)
  • Hope somebody else can make it more efficient

My one line script (running on my Documents folder):

find ~/Documents -type f -exec mdls -name kMDItemKind '{}' \; | sort -u -o DocumentsKind.txt

If it is not obvious, this runs the find command to get all files (-type f), executes the mdls command on its output to get just the Kind metadata, and finally pipes into sort which also removes duplicate lines.

The start of the output file for my Documents folder is:

kMDItemKind = "7-Zip Archive"
kMDItemKind = "AIFF audio"
kMDItemKind = "ASCII graphic document"
kMDItemKind = "Adobe Illustrator File"
kMDItemKind = "Adobe Photoshop PCX file"
kMDItemKind = "Adobe Photoshop actions file"
kMDItemKind = "Adobe Photoshop file"
kMDItemKind = "Adobe Photoshop monitor setup file"
kMDItemKind = "Alias"
kMDItemKind = "Apple icon image"
.......

Method 2 (much easier):

Use the app File List Export from the App Store. For any folder it will list all files beneath it and with lots of attributes. And those attributes include the "Kind".

The huge result table can be exported to a CSV or directly into Excel, where it can be sorted by Kind and duplicates removed.

Note: The two methods didn't give me exactly the same list!

0

"Kind" is a column in List View. Anything that is listed there can be used.

2
  • Thanks, but thats not very helpful. Of course you are right, kind is a column in list view, but what are the possible values ? In addition there are much more keywords in spotlight than columns in the list view. And for none of them is declared or visible what the possible values are.
    – AEberli
    Jun 11, 2021 at 13:57
  • @AEberli Each application defines the data for its own documents. There are as many values as documents.
    – benwiggy
    Jun 11, 2021 at 13:57

You must log in to answer this question.

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