Force Spotlight to Ignore Folders & Files with a Naming Extension in OS X
Spotlight is the core of Mac OS X’s Search functionality, and if you want Spotlight to ignore a file, folder, or drive, the traditionally recommended advice is to drag the items to exclude from indexation into the Spotlight system preference panel exclusion list. That’s the recommended approach because it’s simple to use and easy to manage, but there is another way that utilizes a naming extension to force Spotlight to ignore any given document or directory.
That naming suffix is a “.noindex” extension, and it’s usage is pretty straightforward. Simply renaming something to apply that to the end of any file or folder will prevent Spotlight from including it in the index of searchable files on the Mac. For example:
- “SampleFile” will be indexed and found by Spotlight as usual
- “SampleFile.noindex” will not be indexed and will not be found by Spotlight
The screenshot example shows three different items with the appropriate suffix to exclude them from Spotlight:
Spotlight will not only ignore those files and directories, but it will also ignore everything contained within any folder that has that extension as well.
The obvious problem with this approach is that it changes the actual name of the file or folder to exclude it, where as the primary trick using System Preferences makes no such changes to the name of the item. On the other hand, because it’s handled entirely through the filename it does have it’s benefits, since it can easily be scripted or used remotely through the command line through SSH if necessary.
Occasionally, you may come across OS X adding that extension itself. This often happens after using Migration Assistant to transfer stuff from one Mac to another, and it’s not uncommon to find a folder labeled as “username.noindex” within the /Users/ directory during or after the migration process if it was canceled before the process completed.