I'm trying to set up a Saved Search of my Mac that will exclude files in a folder called 'XYZ' from the search results. The reason is because I'm getting a ton of false positives from that folder that are difficult to sort through.

Just to be clear, I know you can add folders to a "Privacy" list in the Spotlight preferences, but I don't want to add this folder to that list --because I don't want to exclude it from all future searches, just this specific saved search. Any idea how something like this could be done?

  • After some Googling and fiddling with my own test searches I don't think this can be done :(
    – Caesium
    Commented Jul 21, 2012 at 16:32
  • That seems to be the general consensus. Thanks for taking the time to look into it. I'll mark this question as complete if you want to submit that as an answer. Commented Jul 22, 2012 at 7:12

8 Answers 8


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:

  <string>-Documents/Steam Content</string>
  <string>~/Library/Mobile Documents/</string>

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.

  • 1
    You may have discovered something here. This seems to work! Thanks for figuring this out. You've saved me quite a headache -- and likely countless others who will find this question in the future. Commented Jul 22, 2012 at 19:21
  • Shame it can't be done without editing XML but yes, very nicely found :)
    – Caesium
    Commented Jul 22, 2012 at 22:17
  • Anyone know if a folder name can be matched regardless of path? ie. ignore sub-folder /nospotlight in every parent folder, /folder1/nospotlight, /folder2/nospotlight....
    – jb510
    Commented Oct 9, 2012 at 14:00
  • I can confirm that this works by editing files under ~/Library/Saved Searches in OSX 10.10.x Commented Jan 28, 2016 at 12:13
  • 3
    No longer working in Sierra Commented Nov 4, 2016 at 23:32

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: All Those Attributes

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: result

  • 2
    This works, and should have been the selected answer. :) Thank you.
    – Ronixus
    Commented Jun 29, 2013 at 12:56
  • 1
    This doesn't work for me on OSX 10.9.5 Commented Oct 27, 2014 at 22:52
  • 1
    Just checked in 10.10 [Yosemite] and it seems unchanged. I don't have a 10.9 [Mavericks] machine at hand to verify at the moment but I don't recall it being missing. What part doesn't work for you?
    – Lake
    Commented Oct 28, 2014 at 23:19
  • 2
    Possible reason why Document Container may not be usable to exclude folders : apple.stackexchange.com/questions/132860/… (It does not work for me on 10.8.5) Commented Jun 15, 2015 at 18:55
  • 2
    Not working for me in Sierra. Commented Feb 4, 2017 at 14:53

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:

  1. Navigate to iTunes folder, in Finder Menu > File > "New Smart Folder"
  2. In initial search criteria select Kind > is > Folder
  3. Following Lake's lead, in the drop-down created by holding option and (+), select Any of the following are true (this is for opting-in folders) To opt-out folders as Lake mentioned above, change 'Any' to 'None'
  4. 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 "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.

  • 4
    Welcome to the site! Thanks for taking the time to describe your solution in detail If you think a screenshot would help, please upload it to a public sharing site (e.g. Dropbox) and add a link to the answer or in the comments. Somebody with more reputation will then embed it into your answer.
    – nohillside
    Commented May 17, 2013 at 6:06

Currently, I don't think this can be done. There appears to be quite a few people trying to do this that Google finds and nobody has a real answer (other than the Privacy exclusion) :(


In the finder when you are searching for files, you can exclude them by adding minus in front of the criteria. For e.g. I want to search for all the files that is not pdf files, I can write "Kind is -pdf". This seems to work for me.


I am pretty sure that I've found a different way to do this.

In configuring the smart folder, use a Raw Query search attribute. By default, this is not in the search attribute drop down menu, so you will need to find it by clicking Other at the bottom of the drop down menu.

In the input box next to Raw Query, type:

kMDItemPath != "/Users/yourname/Documents/foldertoexclude" 

in which the text in quotation marks is the pathname of the folder to be excluded, which can be found via Get Info.


Based on @Lri answer I wrote an Automator workflow with the apple script below. Not very subtle and still a lot to unfold (eg. relative paths to search folder) but it works as a basic concept.

set savedSearch to path/to/.savedSearch
set exPath to (POSIX path of ((choose folder with prompt "Directory to exclude") as alias)) as text
set userPath to (POSIX path of (path to home folder as alias)) as text
set xmlExclude to "-" & (characters 1 thru -2 of findAndReplaceInText(exPath, userPath, ""))
set cmd to "/usr/bin/plutil -insert SearchCriteria.FXScopeArrayOfPaths.1 -string " & quoted form of xmlExclude & " " & quoted form of savedSearch

do shell script cmd

on findAndReplaceInText(theText, theSearchString, theReplacementString)
    set AppleScript's text item delimiters to theSearchString
    set theTextItems to every text item of theText
    set AppleScript's text item delimiters to theReplacementString
    set theText to theTextItems as string
    set AppleScript's text item delimiters to ""
    return theText
end findAndReplaceInText

on split(theString, theDelimiter)
    set oldDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to theDelimiter
    set theArray to every text item of theString
    set AppleScript's text item delimiters to oldDelimiters
    return theArray
end split

I was too suffering the same problem, and found a way to do so.

Go to Preference system > Spotlight > Select, then select "Privacy" tab, and you can add specific location(s) to exclude in Spotlight search.

I've tried, it works.

  • 1
    Did you miss this part? 'Just to be clear, I know you can add folders to a "Privacy" list in the Spotlight preferences, but I don't want to add this folder to that list --because I don't want to exclude it from all future searches, just this specific saved search.'
    – Jim L.
    Commented Feb 27, 2016 at 15:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .