Jump to content

Use selected file(s) in Finder for a Alfred workflow


Recommended Posts

You can. You can either use hotkeys which has the option to pass the OS X selection into the workflow or you could use AppleScript to grab the selection. Or, you could always use a result action in Alfred. This would allow you to select items in Finder and then press Cmd+Opt+\ and be given a list of actions to perform on the selected files. Some of these actions are built in, more can be added or created via workflows.

Link to comment

In LaunchBar I am used to pressing and holding the activation keyboard shortcut (Command-Space for me) in order to send the selection (file or text) to LaunchBar (ie, the Instant Send feature). Is there any way in Alfred to use this "press and hold" method for passing the selection to Alfred? I find that this is so ingrained in my keyboard habits, it makes it very hard to consider switching to Alfred. I would much rather use press-and-hold than have to remember a separate hotkey sequence just to select something.

Link to comment

In LaunchBar I am used to pressing and holding the activation keyboard shortcut (Command-Space for me) in order to send the selection (file or text) to LaunchBar (ie, the Instant Send feature). Is there any way in Alfred to use this "press and hold" method for passing the selection to Alfred? I find that this is so ingrained in my keyboard habits, it makes it very hard to consider switching to Alfred. I would much rather use press-and-hold than have to remember a separate hotkey sequence just to select something.

 

Unfortunately there isn't a way to use a press-and-hold shortcut for doing this. If there is some other shortcut that you could/would feel more comfortable using, you could set it in the Alfred Preferences. Under the Features area, select File Search, and then select the Actions tab. The area to set the shortcut is located in the bottom of this tab.

Link to comment
  • 3 weeks later...

What's the best way to pass the AppleScript result back to Alfred?

 

Well, ideally for this it would be that you were executing the action from Alfred using the Run Script or Run NSApplescript items. With those you can run Applescript to..

tell application "Finder"
  set currSelection to the selection
end tell

And that would grab the current selection.

 

This could be more easily done with the action hotkey though. The default hotkey for this is Command+Opt+\

Then you would only be creating a workflow that would run as a File Action and would accept whatever files were selected when you pressed the hotkey. This method should be more reliable than trying to use Applescript to get the current selection. Andrew tweaked this method for Alfred 2 to make it MUCH more reliable. There is an outstanding bug in OSX that he reported a while back that makes it not correctly grab the selection sometimes.

Link to comment

The OSX Finder selection bug is easy to reproduce. Select a file in your Desktop. Open a new Finder window and select an item. Usually, Finder will return the Desktop selection instead of the selection of the top most window.

 

Here is a workaround but it activates Finder which is a huge downside:

-- http://lri.me/applescript.html
activate application "SystemUIServer"
tell application "Finder"
	activate
	return selection
end tell
Link to comment

Here is a workaround but it activates Finder which is a huge downside:

 

The Alfred hotkey also allows you to action items in places other than Finder making it more versatile. Thats why I recommended using the Alfred hotkey over some jacky AppleScript to grab the selection.

Link to comment

The Alfred hotkey also allows you to action items in places other than Finder making it more versatile. Thats why I recommended using the Alfred hotkey over some jacky AppleScript to grab the selection.

I've been using Alfred hotkey most of the times. Anyway, It's time to Apple fix such an old and silly bug.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...