Apple - How can I create a Saved Search that excludes a specific folder from the results?
If you hold option
the (+) button to add a search criteria will become a (…) and an Any/All/None
block. Set this to None.
For the criteria select Document Container
. It won't be in the default list alongside Name
, Kind
, etc. Select Other…
to select it from a list of additional criteria so long it has its own search feature:
Set this to the name of the folder that you'd like to exclude using whatever is/contains/begins with/ends with
you find suitable.
The end result should look something like this:
I looked at some of the saved search files in Finder's application bundle, and for example /System/Library/CoreServices/Finder.app/Contents/Resources/MyLibraries/myDocuments.cannedSearch/search.savedSearch
used a format like this for excluding directories:
<key>FXScopeArrayOfPaths</key>
<array>
<string>~/</string>
<string>-Library</string>
<string>-Music/iTunes</string>
<string>-Documents/Steam Content</string>
<string>~/Library/Mobile Documents/</string>
<string>-com~apple~Keynote</string>
<string>-com~apple~Pages</string>
<string>-com~apple~Numbers</string>
</array>
So you can exclude subfolders by adding strings that start with a minus character after a full path. Something like -~/Library
doesn't seem to work.
You can edit savedSearch files by dropping them on a text editor. RawQueryDict:SearchScopes
and FXScope:FXScopeArrayOfPaths
seem to list the same paths by default, but just editing the second one appeared to exclude folders at least in Finder.
I want to add that if "Document Container" is not working for you (such as is my problem), you can set the Search Folder to opt in/out specific folders.
Pardon me, I do not have the "reps" to post images so I will do my best. This is my first post so feel free to flame away.
For my music organization work-flow, I wanted the iTunes folder to hide erroneous sub-folders. Of course, moving folders out of the iTunes folder was not an option since it would break/freak-out iTunes into re-creating those same folders. Here is how I accomplished this by tweaking Lake's above method:
- Navigate to iTunes folder, in Finder Menu > File > "New Smart Folder"
- In initial search criteria select
Kind
>is
>Folder
- Following Lake's lead, in the drop-down created by holding
option
and (+), selectAny
of the following are true
(this is for opting-in folders) To opt-out folders as Lake mentioned above, change 'Any' to 'None' - Since I am "Opting in" folders I then nested 5 criteria underneath the
Any
option which looked like this (actual folder names are used for example):
Name
is
"Automatically Add to iTunes"
Name
is
"Music"
Name
is
"MUSIC TO ADD - MAIN FOLDER"
Name
is
"TuneUp Results"
Name
is
"MusicBrainz Tagging"
So the end result is that when I click on the Smart Search (located in the Finder sidebar for me) I will only see the 5 folders I want to without destroying the inherent folder layout of the main folder the reside in.
I do hope this helps.