Skip to content

Instantly share code, notes, and snippets.

@gistub
Last active July 24, 2022 00:55
Show Gist options
  • Select an option

  • Save gistub/a94dd5fd25221334a14390c2bfdb623f to your computer and use it in GitHub Desktop.

Select an option

Save gistub/a94dd5fd25221334a14390c2bfdb623f to your computer and use it in GitHub Desktop.
[macOS: mdfind query ] How to find and create queries for Spotlight/Finder #macos #spotlight #mdfind

Figure out queries generated by macOS

  • Do a search in Finder, save it. Then find the saved search in ~/Library/SavedSearch and 'Get Info'

Gel list of all attirbutes

  • Run mdimport -X or mdimport -A

Examples

  • Find all files containing instmodsh mdfind '(** = "instmodsh*"cdw)'

  • Find only in $HOME files named/containing 'git.3', whose display name is 'git' and whose parent folder is not 'man' mdfind -onlyin $HOME '((** = "git.3*"cdw) && (kMDItemDisplayName = "*git*"cd) && (kMDItemDocumentContainer != "man"cd))'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment