I've been trying to make Spotlight more useful to me, and one of the first things that came to mind was changing the categories of files that it searches. I rarely if ever search for Bookmarks, Fonts, Mail Messages, Contacts, System Preferences, or Events and To Do Items, and was wondering if I could replace them with something more convenient.
Anyway, it turns out that this is possible, although not as completely as I would have hoped. You can quite straightforwardly change an existing category to list a different type of file. Note that this does not stop Spotlight from showing files in the category you replace, it just makes them show up as normal documents. You can also add a new category. However, if you do this, it will only show up in the results window, not in the list that drops down from the menubar or in System Preferences. Changing an existing category will probably be more useful to most people.
Warning: these methods involve modifying five system files. You may completely stuff up Spotlight, or your entire system, if you do something wrong. Read on for the step-by-step...
[robg adds: I have not tested this one, and it does require editing some relatively deeply-buried system files. However, the concept seems amazingly useful; hopefully Apple adds the ability for self-created categories in 10.5 (or some enterprising coder adds a third-party GUI app for it in 10.4). For this one, though, proceed at your own risk.]
Before changing anything, make sure you back up by running these commands in the Terminal (just copy and paste to a Terminal window):
$ sudo cp /System/Library/CoreServices/Search.bundle/Contents/\
Resources/MDSimpleGrouping.plist /System/Library/CoreServices/\
Search.bundle/Contents/Resources/MDSimpleGrouping.plist.backup
$ sudo cp /System/Library/CoreServices/Search.bundle/Contents/\
Resources/English.lproj/MDSimpleGrouping.strings /System/Library/\
CoreServices/Search.bundle/Contents/Resources/English.lproj/\
MDSimpleGrouping.strings.backup
$ sudo cp /System/Library/Frameworks/CoreServices.framework/\
Versions/A/Frameworks/Metadata.framework/Versions/A/Resources/\
MDPredicate.plist /System/Library/Frameworks/CoreServices.\
framework/Versions/A/Frameworks/Metadata.framework/Versions/A/\
Resources/MDPredicate.plist.backup
$ sudo cp /System/Library/Frameworks/CoreServices.framework/\
Versions/A/Frameworks/Metadata.framework/Versions/A/Resources/\
English.lproj/MDPredicateKeywords.plist /System/Library/\
Frameworks/CoreServices.framework/Versions/A/Frameworks/\
Metadata.framework/Versions/A/Resources/English.lproj/\
MDPredicateKeywords.plist.backup
$ sudo cp /System/Library/PreferencePanes/Spotlight.prefPane/\
Contents/Resources/English.lproj/Localizable.strings /System/\
Library/PreferencePanes/Spotlight.prefPane/Contents/Resources\
/English.lproj/Localizable.strings.backup
Once that's done, here's how to tweak Spotlight to match your needs...
"com.apple.safari.bookmark" = "BOOKMARKS";
to this:
"com.microsoft.word.doc" = "BOOKMARKS";
Save and close the file. Then open /System -> Library -> CoreServices -> Search.bundle -> Contents -> Resources -> English.lproj -> MDSimpleGrouping.strings, and replace this line:
"BOOKMARKS" = "Bookmarks";
with something more representative:
"BOOKMARKS" = "Word Documents";
Save and quit your editor. Now documents of type com.microsoft.word.doc will fall under the category with dummy name BOOKMARKS, but will be labeled as Word documents.BOOKMARKS = "kMDItemContentTypeTree = com.apple.safari.bookmark";
with:
BOOKMARKS = "kMDItemContentTypeTree = com.microsoft.word.doc";
Save and close the file. Then open /System -> Library -> Frameworks -> CoreServices.framework -> Versions -> A -> Frameworks -> Metadata.framework -> Versions -> A -> Resources -> English.lproj -> MDPredicateKeywords.plist and change:
<key>BOOKMARKS_STRINGS_LOCALIZED</key><br>
<array><br>
<string>kind:bookmark</string><br>
<string>kind:bookmarks</string><br>
</array>
to something like:
<key>BOOKMARKS_STRINGS_LOCALIZED</key><br>
<array><br>
<string>kind:word</string><br>
<string>kind:word document</string><br>
</array>
(or choose your own keywords). Save and quit."CATEGORY_BOOKMARKS" = "Bookmarks";
to this:
"CATEGORY_BOOKMARKS" = "Word Documents";
Save and quit.killall SystemUIServer
When the Spotlight icon reappears in the menubar, Word documents should have their own category, and you should be able to find all the Word docs on your computer by typing kind:word. The only minor catch is that the wrong icon is displayed for the new category in the Spotlight prefpane (icon data seems to be stored in /System -> Library -> PreferencePanes -> Spotlight.prefPane -> Contents -> Resources -> icons.data, and can't be easily changed).Mac OS X Hints
http://hints.macworld.com/article.php?story=20060729190236629