Jump to content

Disable filename copy on action invoke


Recommended Posts

I've set up a workflow that simply opens the selected file in Finder in my text editor.

 

When I invoke the action, the selected file's name is copied to the clipboard. This is frustrating, since a common use-case is that I copy text from somewhere else, open a file with the workflow, and paste the text.

 

Is there a way to disable copying the filename when the action is invoked?

 

Thanks!

Link to comment

@Jamie Welcome to the forum! Before asking workflow-related questions, please fill in your Powerpack email address in your forum profile. This is only visible to admins and allows us to confirm your Powerpack user status.

 

Cheers,
Vero

Link to comment

@Vero Thanks, I've added my Powerpack email to my profile.

 

@dfay It's a 2-step workflow using the Hotkey trigger and the Open File action. I've uploaded screenshots with the settings. Note that I'm using Alfred v2.9

 

Alfred workflow 1.png

Alfred workflow 2.png

Edited by Jamie
Link to comment

I have only ever used Selection in OS X to capture text....I would do this with a File Action (even though it's an extra step....)

 

But you can do it the way you want by leaving Argument as None, then connecting it to a script action (osascript/AS) with the following AppleScript

 

tell application "Finder"
   set sel to selection
   if sel is not {} then
       set filepath to item 1 of sel as text --> The path to the one selected item.
       open filepath using application file id "com.apple.TextEdit" -- bundle identifier of the designated application
   end if
end tell

 

Link to comment
  • 11 months later...

Update: After using the solution described below, I realized there's an option in Advanced preference section, "Selection Hotkeys", that can be set to "Restore previous clipboard item"; this is the simpler way to solve the issue.

 

 

@dfay Didn't get a chance to look further into this until now, but your solution does work, thank you so much.

 

The issue with my original workflow setup seems to be that the Hotkey object type with Argument set to "Selection in macOS" will cause that selection to be copied to the clipboard. I've also been able to adapt the script as follows to use Hotkey (Argument set to None) to trigger script to get selection and then Browse in Alfred. Thanks again!

on alfred_script(q)  
 tell application "Finder"
   set sel to selection
   if sel is not {} then
       set filepath to POSIX path of (item 1 of sel as text)
   end if
 end tell
end alfred_script

 

 

 

 

Edited by Jamie
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...