Mac OS X 10.4 (Tiger) Tip: Create a smart folder for file name searches

Posted by Pierre Igot in: Macintosh
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:

  1. Open a new Finder window.
  2. Type command-F.
  3. Choose the focus for your search (either “Computer” or a specific folder or volume).
  4. Click on the “+” button to add another search criterion.
  5. Select “Name” as the desired attribute for that third criterion.
  6. Type “bogus” as the keyword in the “Name › Contains ›” field. This will search for files and folders whose name contains “bogus.”
  7. Delete the first two criteria (“Kind › Any” and “Last Opened › Any Date”) by clicking on their “” button.
  8. 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.)
  9. 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.)
  10. In the file, go to the section starting with “<key>RawQuery</key>.” Select the text between <string> and </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 <string> and </string>.)
  11. Then go to the section starting with “<key>FXCriteriaSlices</key>” and go down to “<key>Value</key>.” Select the text between <string> and </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.
  12. 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.


3 Responses to “Mac OS X 10.4 (Tiger) Tip: Create a smart folder for file name searches”

  1. DeadParrot24 says:

    Silly editor messed up all the < and > items. (and no preview). Hopefully this is better.

    You need to modify
    /System/Library/CoreServices/Finder.app/Contents/Resources/default_smart.plist
    Take all the usual precautions (work on a backup, etc.).

    Change

    <string>Skin</string>
    <key>Value</key>
    <string>KI**</string>

    To

    <string>Snam</string>
    <key>Value</key>
    <string></string>

    Delete

    <dict>
    <key>FXSliceKind</key>
    <string>Slsv</string>
    <key>Value</key>
    <string>DA**</string>
    </dict>

    Restart the Finder. Now when you Command-F, you will search for a Name.

    (Hope this works).

  2. Pierre Igot says:

    Thanks — indeed the Mac OS X Hints post that I am referring to was actually about this, i.e. about modifying the default behaviour of command-F. However, I am not interested in modifying the default behaviour, I just want a smart folder for searches by name.

    Modifying files in System is obviously at your own risk, plus needs to be restored each time you do a system install/update.

  3. MHC-in-the-box » Some Mac OS X Tiger (10.4.x) tricks says:

    […] Here a trick I’m sure can be very handy! Mac OS X 10.4 (Tiger) Tip: Create a smart folder for file name searches. […]

Leave a Reply

Comments are closed.