Jump to content
Jamie

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!

Share this post


Link to post

@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

Share this post


Link to post

@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

Share this post


Link to post

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

 

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...