Smart folder filter “does not contain”

smart-folders

Smart Folder Exclude Folder

Ultimately I want the result of this find command to be a smart folder.

The criteria aren't that complicated:

  • name should be "README.md"
  • type should be file
  • path should not contain "node_modules"

find /Users/me/Documents -type f -name README.md -not -path "*/node_modules/*"

The problem is that the smart folders criteria operator list seems to be lacking a does not contain option.

The available options are:

  • matches
  • contains
  • begins with
  • ends with
  • is
  • is not

Is it possible to accomplish this and if so then how?

Edit 1

I found that by holding the option key I am able to add a negation clause to the smart folder search criteria but I cannot seem to successfully exclude the node_modules folder. It is unclear which criteria to use but none of the ones I have tried seem to work:

  • Document Container
  • Containing Folder Names
  • Folder Name

I have tried combining these with the following operators:

  • contains
  • matches

and with the following terms:

  • node_modules
  • node_modules

in case it supports wildcard searches.

I have tried all combinations of the above filters, operators and terms.

The documentation is so poor on the subject.

enter image description here

Best Answer

It looks like kMDItemPath can't do what you need:

no-results-in-spotlight-in-searches-against-kmditempath

Some potential alternatives are discussed here:

how-to-locate-a-file-in-spotlight-using-folder-and-file-name