Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
    
After some Googling and fiddling with my own test searches I don't think this can be done :( –  Caesium Jul 21 '12 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. –  user1457323 Jul 22 '12 at 7:12
add comment

7 Answers 7

up vote 5 down vote accepted

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.

share|improve this answer
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. –  user1457323 Jul 22 '12 at 19:21
    
Shame it can't be done without editing XML but yes, very nicely found :) –  Caesium Jul 22 '12 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 Oct 9 '12 at 14:00
add comment

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

share|improve this answer
1  
This works, and should have been the selected answer. :) Thank you. –  Ronixus Jun 29 '13 at 12:56
add comment

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 "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.

share|improve this answer
1  
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. –  patrix May 17 '13 at 6:06
add comment

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) :(

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.