<p>I've got bunches of auxiliary files that are generated by code and LaTeX documents that I dearly wish <em>would not</em> be suggested by SpotLight as potential search candidates. I'm not looking for <code>example.log</code>, I'm looking for <code>example.tex</code>!</p>

<p>So can Spotlight be configured to ignore, say, all <code>.log</code> files?</p>

<p>(I know, I know; I should just use QuickSilver instead…)</p>

<hr>

<p>@<a href="https://stackoverflow.com/questions/41279/can-mac-os-xs-spotlight-be-configured-to-ignore-certain-file-types#41295">diciu</a> That's an interesting answer. The problem in my case is this:</p>

<blockquote>
  <p>Figure out which importer handles your type of file</p>
</blockquote>

<p>I'm not sure if my type of file is handled by any single importer? Since they've all got weird extensions (.aux, .glo, .out, whatever) I think it's improbable that there's an importer that's <em>trying</em> to index them. But because they're plain text they're being picked up as generic files. (Admittedly, I don't know much about Spotlight's indexing, so I might be completely wrong on this.)</p>

<hr>

<p>@<a href="https://stackoverflow.com/questions/41279/can-mac-os-xs-spotlight-be-configured-to-ignore-certain-file-types#41342">diciu</a> again: <code>TextImporterDontImportList</code> sounds very promising; I'll head off and see if anything comes of it.</p>

<p>Like you say, it does seem like the whole UTI system doesn't really allow <em>not</em> searching for something.</p>

<hr>

<p>@<a href="https://stackoverflow.com/questions/41279/can-mac-os-xs-spotlight-be-configured-to-ignore-certain-file-types#41377">Raynet</a> Making the files invisible is a good idea actually, albeit relatively tedious for me to set up in the general sense. If worst comes to worst, I might give that a shot (but probably after exhausting other options such as QuickSilver). (Oh, and SetFile requires the Developer Tools, but I'm guessing everyone here has them installed anyway <code>:)</code> )</p>

[{'answer_id': 41283, 'author': 'D2VIANT', 'author_id': 4365, 'author_profile': 'https://Stackoverflow.com/users/4365', 'pm_score': 2, 'selected': False, 'text': '<p>Not sure how to do it on a file type level, but you can do it on a folder level:</p>\n\n<p>Source: <a href="http://lists.apple.com/archives/spotlight-dev/2008/Jul/msg00007.html" rel="nofollow noreferrer">http://lists.apple.com/archives/spotlight-dev/2008/Jul/msg00007.html</a></p>\n\n<p><strong>Make spotlight ignore a folder</strong></p>\n\n<p>If you absolutely can\'t rename the folder because other software depends on it another technique is to go ahead and rename the directory to end in ".noindex", but then create a symlink in the same location pointing to the real location using the original name.</p>\n\n<p>Most software is happy to use the symlink with the original name, but Spotlight ignores symlinks and will note the "real" name ends in *.noindex and will ignore that location.</p>\n\n<p>Perhaps something like:</p>\n\n<blockquote>\n  <p>mv OriginalName OriginalName.noindex\n  ln -s OriginalName.noindex<br>\n  OriginalName</p>\n  \n  <p>ls -l</p>\n  \n  <p>lrwxr-xr-x 1 andy admin 24 Jan 9 2008\n  OriginalName -> OriginalName.noindex\n  drwxr-xr-x 11 andy admin 374 Jul 11\n  07:03 Original.noindex</p>\n</blockquote>\n'}, {'answer_id': 41295, 'author': 'diciu', 'author_id': 2811, 'author_profile': 'https://Stackoverflow.com/users/2811', 'pm_score': 2, 'selected': False, 'text': '<p>Here\'s how it <i>might</i> work.</p>\n\n<p><b>Note</b>: this is not a very good solution as a system update <i>will</i> overwrite changes you will perform.</p>\n\n<p>Get a list of all importers</p>\n\n<pre>\ncristi:~ diciu$ mdimport -L\n2008-09-03 10:42:27.144 mdimport[727:10b] Paths: id(501) (\n    "/System/Library/Spotlight/Audio.mdimporter",\n    "/System/Library/Spotlight/Chat.mdimporter",\n    "/Developer/Applications/Xcode.app/Contents/Library/Spotlight/SourceCode.mdimporter",\n</pre>\n\n<p>Figure out which importer handles your type of file (example for the Audio importer):</p>\n\n<pre>\ncristi:~ diciu$ cat /System/Library/Spotlight/Audio.mdimporter/Contents/Info.plist \n\n\n\n\n[..]\n            CFBundleTypeRole\n            MDImporter\n            LSItemContentTypes\n            \n                public.mp3\n                public.aifc-audio\n                public.aiff-audio\n\n</pre>\n\n<p>Alter the importer\'s plist to delete the type you want to ignore.</p>\n\n<p>Reimport the importer\'s types so the system picks up the change:</p>\n\n<pre>\nmdimport -r /System/Library/Spotlight/Chat.mdimporter\n</pre>\n'}, {'answer_id': 41342, 'author': 'diciu', 'author_id': 2811, 'author_profile': 'https://Stackoverflow.com/users/2811', 'pm_score': 3, 'selected': True, 'text': '<p>@Will - these things that define types are called <a href="http://developer.apple.com/macosx/uniformtypeidentifiers.html" rel="nofollow noreferrer">uniform type identifiers</a>.</p>\n\n<p>The problem is they are a combination of extensions (like .txt) and generic types (i.e. public.plain-text matches a txt file without the txt extension based purely on content) so it\'s not as simple as looking for an extension.</p>\n\n<p>RichText.mdimporter is <i>probably</i> the importer that imports your text file.\nThis should be easily verified by running mdimport in debug mode on one of the files you don\'t want indexed:</p>\n\n<pre>\ncristi:~ diciu$ echo "All work and no play makes Jack a dull boy" > ~/input.txt\ncristi:~ diciu$ mdimport -d 4 -n ~/input.txt 2>&1 | grep Imported\n    kMD2008-09-03 12:05:06.342 mdimport[1230:10b] Imported \'/Users/diciu/input.txt\' of type \'public.plain-text\' with plugIn /System/Library/Spotlight/RichText.mdimporter.\n\n</pre>\n\n<p>The type that matches in my example is public.plain-text.</p>\n\n<p>I\'ve no idea how you actually write an extension-based exception for an UTI (like public.plain-text except anything ending in .log).</p>\n\n<p>Later edit: I\'ve also looked though the RichText mdimporter binary and found a promising string but I can\'t figure out if it\'s actually being used (as a preference name or whatever):</p>\n\n<pre>\ncristi:FoodBrowser diciu$ strings /System/Library/Spotlight/RichText.mdimporter/Contents/MacOS/RichText |grep Text\n\nTextImporterDontImportList\n\n</pre>\n'}, {'answer_id': 41377, 'author': 'Raynet', 'author_id': 4294, 'author_profile': 'https://Stackoverflow.com/users/4294', 'pm_score': 1, 'selected': False, 'text': "<p>The only option probably is to have them not indexed by spotlight as from some reason you cannot do negative searches. You can search for files with specifix file extension, but you cannot not search for ones that don't match.</p>\n\n<p>You could try making those files invisible for Finder, Spotlight won't index invisible files. Command for setting the kIsInvisible flag on files is:</p>\n\n<p>SetFile -a v [filename(s)]</p>\n"}]
['https://Stackoverflow.com/questions/41279', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4161/']