I have this folder structure:
How do I search in Photos excluding the Videos subfolder?
I don't want to permanently exclude the subfolder from Spotlight, just for this particular search.
Based on the directory structure in your example and assuming you wish to search for the files whose extension, for example, includes the keyword
mpv under the
Photos directory or any of its subdirectories, but not the
Videos directory right under it, you can use the
find command through the Terminal app as follows:
find . -name "*.*mpv*" -o -path ./Videos -prune
The command above assumes you are in the
Photos directory in the Terminal app as you issue this command.
If you wish to search for the files whose extensions include either the keyword
mpv or just
avi with other criteria being the same as above, you can use the following
find . \( -name "*.*mpv*" -o -name "*.avi" \) -o -path ./Videos -prune
You can search for as many extensions as you like at the same time using
find by adding more keywords in between
\) as shown above.
-o serves as the logical operator OR.