July 28th, 2005 • 3:19 pm
One of the irritating aspects of Mac OS X 10.4′s Spotlight feature is that it’s become more difficult to do a simple search for file names. By default, when you type a keyword in Spotlight or in the Finder’s search field, Spotlight searches for files where the keyword appears anywhere, i.e. either in the file name or in the properties or in the content of the file.
This can often lead to tons of irrelevant results, and cause a significant slow-down in Spotlight. There is, of course, a way to circumvent this problem, which is to open a new Finder window, press
command-F to make the search criteria appear, add a search criterion with the “+” button, select “Name” as the attribute and type the desired keyboard in the field next to the “Name” attribute.
(During the Apple Seed program for Tiger, I tried to get Apple to include the “Name” attribute as one of the default attributes when you start a search, i.e. when you press
command-F, but they obviously wouldn’t listen to me. The default attributes are “Kind” and “Last Opened,” with respectively the values “Any” and “Any Date.” I don’t really know how useful it is to have those two as the two default criteria.)
The trouble with this is that it is very painful to have to go through all these steps each and every time you want to search for a file or folder by name. Is there a way to speed up the process?
Yes and no. The problem is that you can only save such a search as a smart folder if you have typed something (anything) either in the general search field or in the “Name › Contains ›” field. As long as you haven’t typed anything, the search cannot be saved as a smart folder.
In other words, if you want to save this as a smart folder, you have to type a bogus keyword. Then the next time you open the saved smart folder, Mac OS X will automatically list all the results for that particular bogus keyword, and you’ll have to edit the field by selecting the bogus keyword and replacing it with the one you actually want. Not very elegant!
There is no way to design a complete elegant solution, but thanks to this Mac OS X Hints tip, I have found a way to improve things somewhat. This hint indicates how you can remove the bogus keyword and get an empty “Name › Contains ›” field instead by default when you open the smart folder, and it also indicates how you can prevent Mac OS X from doing a search for names matching the bogus keyword by default when you open the smart folder.
In order to achieve this, do the following:
- Open a new Finder window.
- Type command-F.
- Choose the focus for your search (either “Computer” or a specific folder or volume).
- Click on the “+” button to add another search criterion.
- Select “Name” as the desired attribute for that third criterion.
- Type “
bogus” as the keyword in the “Name › Contains ›” field. This will search for files and folders whose name contains “
- Delete the first two criteria (“Kind › Any” and “Last Opened › Any Date”) by clicking on their “-” button.
- Click on “Save” to save the search as a smart folder. Call it “Search by Name,” for example, and save it on your desktop. This will put a smart folder called “Search by Name.savedSearch” on your desktop. (The “.savedSearch” extension will only be visible if you have set the Finder to show file extensions by default.)
- Open the file “Search by Name.savedSearch” with a text editor such as BBEdit or TextEdit. You can do this by dragging the smart folder icon onto the icon of the text editor. (A smart folder is just a text file containing XML code.)
- In the file, go to the section starting with “
<key>RawQuery</key>.” Select the text between
</string>and delete it. This will prevent Mac OS X from doing the search for “
bogus” by default when you open the smart folder. (You’ll see “
bogus” as a keyword in the query text that appears between
- Then go to the section starting with “
<key>FXCriteriaSlices</key>” and go down to “
<key>Value</key>.” Select the text between
</string>and delete it. The text to delete should be the “
bogus” keyword you typed earlier on as the name to search for, when you created the smart folder.
- Save the file and close it.
Et voilà! Now you have a smart folder that has a single criterion with the attribute “Name” by default and no bogus keyword typed in the “Name › Contains ›” field by default (so that you don’t have to select it and delete it first). And it’s also a smart folder that will not do any search until you’ve actually typed a keyword in the “Name › Contains ›” field.
Unfortunately, when you open this smart folder, by default the search criterion is hidden, and you have to click on the “Edit” button to make it visible. As far as I know, there is no trick available to force Mac OS X to open a smart folder with its search criteria visible by default. (It’s another feature request that I have submitted to Apple, so far with no success…)
But at least with this tip you will save yourself a number of very tedious steps when all you want to do is to search for keywords in file/folder names.