10.4: Search for multiple Spotlight comments

Jun 03, '05 11:53:00AM

Contributed by: Wolverine

Tiger only hintNormally when you perform a Finder search for files that have Spotlight comments, you're limited to searching for a single phrase or word or comment. You can't search for multiple comments from within the same search field, nor can you add additional search fields, because then Finder thinks you're seeking all of the variables at once. However, with the Raw Query, you can easily search for multiple Spotlight comments with the following string:

(kMDItemFinderComment = "*text*")
The * characters placed before and after the word force the search to look for that word, but not limit itself by any other text around it (without the asterisks, the query becomes absolute for just that text and nothing else). For example, if you have one type of Spotlight comment that is Mac OS X Hints and another that is Unix Hints, then you can use the following string to find files possessing both types:
(kMDItemFinderComment = "*Hints*") 
If you want to find all files with Hints comments, but also limit to them comments offset by the word Rob (i.e. Mac OS X Hints by Rob as opposed to Mac OS X Hints by Wolverine), then you can write it as follows in the same search field:
(kMDItemFinderComment = "*Hints*") && (kMDItemFinderComment = "*Rob*")
The double && characters mean "AND" in this case. You can also use || to mean "OR", such as:
(kMDItemFinderComment = "*Hints*") || (kMDItemFinderComment = "*hints*")
That search will find all comments that contain either the words "Hints" or "hints". This picture shows a sample smart search using these constructs.

Finally, you don't need to limit yourself to the Raw Query strings that you know -- you can easily find out what strings are available on a given file by going into the Terminal, finding the file, then typing mdls filename.ext or mdls "File Name.ext". Here's an example.

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050521041052574