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.

Tip:
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

  1. Stepcraft says:

    I just discovered another way to set the finder to default “find by name” (search by file name). I’m using Mac OS X 10.8.5 Mountain Lion. I’m not sure if this works on other OS versions, but it probably does.

    Here’s a step by step:

    1: Open System Preferences

    2: Click on “Keyboard”

    3: Click on “Keyboard Shortcuts”

    4: Click on “Application Shortcuts” (on my system this was the last item located on the left-hand side window)

    5: Click the little “+” right below the right-hand side window

    6: Click on the “Application” menu and choose “finder.app”

    7: Click into the field “Menu Title:” and type “Find by Name…” (Type it exactly like that including the three dots. Don’t type the quotes BTW.)

    8: Click into the field “Keyboard Shortcut:” and press the command-key and F at the same time. It should look like this ⌘F

    9: Close System Preferences

    That’s it. Basically what you are doing is remapping the command-F key (⌘F) to “Find By Name”.

    :)

  2. Marc says:

    You’ll be happy you moved. It took me about 3-4 months to get used to it, but now there’s no chance I’d go back!

  3. ALW says:

    Thanks, huge help, we just moved our entire work system to leopard, and “contents” popping up on default was driving me mad, every helpful post moves us all closer to a collective conciseness, can’t wait!

  4. Marc says:

    haha, I figured that out after I got this to work. I had made a note of it in the top paragraph but I guess it wasn’t that visible so I’ve highlighted it. thanks!

  5. Hansaplast says:

    Did you ever try Command+Shift+F …? Does search by filename out of the box … (tried it just now on 10.6.7)

Leave a Reply

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