3

-onlyin

option in mdfind searches a particular folder.
How do I exclude certain folders in combination with -onlyin?

Thus if I want to search the entire folder SearchHere containing folders A , B and C and exclude from searching within C.

pal4life
  • 3,210
  • 5
  • 36
  • 57

1 Answers1

1

You could use something like:

mdfind -onlyin SearchHere 'kMDItemFSName==ItemToSearch' | grep -v '/C/'

mdfind seems to ignore kMDItemPath, so using grep -v should solve the issue.

l'L'l
  • 44,951
  • 10
  • 95
  • 146