Smart Folders: Rule with Containing Folder Name?

I want to create a (what I assumed would be) simple Smart Folder. Basically “Show me all files that have tag tagname that are not in folder foldername”.

Surprisingly, I can’t make it work. I have searched the web but can only find generalised articles. Finding files with the tags is basic, excluding those residing in a specific folder not so much. There seem to be three search attributes that appear relevant: Folder Name, Document Container, and Containing Folder Names. None seem to work :frowning:

So either this can’t be done or I am missing something really obvious.

Anyone know if and how this can be done?

A Google search also leads me to believe that it can’t be done – those attributes seem to somehow apply only to iCloud or XCode, although I don’t quite get that.

However I did find something that might help – tag everything in that folder with a tag Ignore then search for files that have tag tagname and don’t have the tag Ignore