Set Finder to Search “File Name” instead of “Contents” on Mac OS X Leopard

Here’s my solution to getting the “File Name” box by default when pressing Cmd-F when in a finder window on Mac OS X. This is not perfect, but it’s pretty good. Since it has to call automator / applescrpt there might be a 1 second delay after you press the key. Let me know if anybody has a way to speed that up. So…

Note: There is an easier way to do this (than below). Instead of using cmd-f just use cmd-shift-f and it will default to file name instead of contents :) However, if you are really set on having Cmd+f search file names, check out the section below.

Part I: Create a Service with Automator

  • Launch Automator and choose “New Service”
  • Click on the record button and when it is recording, choose a finder window, and do something, like change the view prefernces (icons, list, anything really). Then press stop recording.
  • Back in automator you will now have your recording, but at the top you will also have something that says “Service Receives” and change that from “text” to “no input” and then choose “Finder” for the application. If you didn’t do the previous step of recording something where you activated finder, you won’t be able to select finder her.
  • Remove the thing you recorded in the right hand pane, and then choose Applescript from the left side. Paste in this code:
on run {input, parameters}
    tell application "System Events" to tell process "Finder"
        set frontmost to true
        click menu bar 1's menu bar item "File"'s menu 1's menu item "Find"
        tell application "Finder"
        end tell
        tell window 1's splitter group 1
            click group 1's radio group 2's checkbox "File Name"
        end tell
    end tell

    return input
end run
  • You should then have something that looks like the image below.
  • Save that with a name like SearchFile (no spaces)

Part 2: Assign that Service to Command-F in system preferences

  • Open System Preferences and then Keyboard
  • Choose Application Shortcuts in the Left Side and then Add New
  • Choose Finder as the Application, then type SearchFile as the menu name, and choose your keyboard shortcut (Cmd-F)
  • Voila! When you are in Finder this keyboard shortcut will override the default cmd-f and run your applescript, which will open the find box and then select the “File Name” as the default search toggle.

If you are not already aware, if you want to change the default search behavior to “This Folder” instead of “This Mac” – right click in the places bar of finder (you must have the toolbar visible to see this area) and then choose Open Sidebar Preferences. Then click on the advanced tab, and you will be able to change that option, too:

Related Posts:

  • No Related Posts
This entry was posted in Mac, Tech Tips and tagged , , , , . Bookmark the permalink.

5 Responses to Set Finder to Search “File Name” instead of “Contents” on Mac OS X Leopard

Leave a Reply

Your email address will not be published. Required fields are marked *