Question

Finder's Open/Save File dialog is actually very dumb (in terms of flexibility). When I look for a file or its location, I can probably find it much faster using Alfred.

However, in many cases, you just have to use that dialog. Not particularly when you open files, but for example when you specify the place to save them.

As I'm a keyboard-only user (at least for 99% of the time), I find it tedious to launch Alfred, and reveal the file/directory in Finder and drag it (or its proxy icon) to the dialog in order to open/save it.

Is there any way I can get a keyboard-only, fuzzy-matching style file/folder selection mechanism for this dialog?

I could imagine using Alfred and AppleScript for that, but I don't know where to start. The end result would be that I could just select the appropriate file or folder via Alfred.

Note that:

  • I have the Alfred Powerpack, so AppleScript is possible.
  • I know Alfred has an "Open with…" action. This is not the same.
  • I know I can go to folders with G, but it's weak in comparison to what a real shell offers.
  • I know you can Spotlight-search in that dialog, but I prefer Alfred's capabilities.

Update, 5 years later: I came looking for a solution for this and stumbled upon my own question. I also found this thread in which people have suggested several workflows, but the only one that would actually directly work is now a dead link (don't you just love it when text-only stuff is hosted on someone's Dropbox?).

Was it helpful?

Solution 2

Five years later, I found a solution using an older AppleScript that was posted here, which wasn't working anymore because the Go to… window uses a ComboBox instead of a TextField.

Here's how to use that in Alfred:

  • Create a new workflow
  • Insert a File Action
  • Insert a Run NSAppleScript action and connect the two
  • Paste the script below
  • Save the workflow and give it a proper name and bundle identifier

To use it in practice, wait for a file selection dialog to open, then launch Alfred, select the file/folder you want, and run the action you just created.

Here's the script:

on alfred_script(q)
set filePath to POSIX path of q as text

tell application "System Events"
    set theApplication to application processes whose frontmost is true
    set target to item 1 of theApplication
    set target to a reference to front window of target
    set target to a reference to front sheet of target
    delay 0.5
    tell target to keystroke "g" using {command down, shift down} -- Activate goto field
    delay 0.5
    tell target
        set value of combo box 1 to filePath
        delay 0.5
        key code 36 -- simulate pressing the Enter key
    end tell
end tell
end alfred_script

OTHER TIPS

Once you find the file using Alfred, you can copy its path to the clipboard and paste that path into the Go to Folder tool of open/save dialogs.

Find your file in Alfred, press the right arrow key to view the list of operations for that file, the up arrow key to go to the last option (Copy path to clipboard), and then the enter key to activate that option.
Switch back to the open/save dialog, press cmd-shift-g to open the Go to Folder dialog, paste the path in, and hit enter. The file will be selected and you can hit Enter to open/save.


If you're interested in getting some more flexibility out of Open/Save dialogs, I highly recommend Default Folder X. It's immensely powerful and customizable and could eliminate the need for workarounds like this.
$35, 30 day trial

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top