4

What commands do we have for finding tagged files/folders using find on the command line?

I have done a search and looked on this site and found nothing.

3
  • Yes - "tag" is one of those words that doesn't yield particularly relevant search results! You should put your GitHub find in an answer - more people will see it.
    – Seamus
    Commented Aug 24, 2020 at 0:14
  • @anki I already marked this as answered and the answer contains exactly what you liked to.
    – John
    Commented Jan 26, 2022 at 16:01
  • sorry the duplicate comment text is worded like that. It's just bookkeeping. I was merging similar questions like apple.stackexchange.com/questions/435931/…
    – anki
    Commented Jan 26, 2022 at 16:03

2 Answers 2

5

The correct command to perform Spotlight searches on the macOS Terminal command line is mdfind.

mdfind "kMDItemUserTags == '<your_tags_here>'"

The list all the kMD codes:

mdimport -A
2
  • 2
    I marked your answer as accepted. There is a package on GitHub that also works.
    – John
    Commented Aug 22, 2020 at 20:24
  • Nice find, very interesting. Commented Aug 22, 2020 at 20:58
4

Turns out you can do something as simple as:

mdfind 'tag:Blue' 

Although this will only work in English locales

See this excellent answer that happens to discuss tags: https://stackoverflow.com/a/30281424/404459

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