Jump to content
luckman212

Best way to "Choose File" from inside a workflow?

Recommended Posts

I've got a workflow where at some point I want the user to select an image file from the disk. Right now, I'm using Run NSAppleScript (cached) for this.

on alfred_script(q)
  activate
  set p to "Select an image to process:"
  set theImage to choose file with prompt p of type {"public.image"}
  return (POSIX path of theImage) as text
end alfred_script

Is this "right" ? Is there a faster, better or more efficient way?

 

I ask because it feels "slow" when this step is triggered—much slower than native Alfred objects and File Navigation windows, not to mention that AppleScript seems to be going the way of the dodo.

 

So if there's a way to avoid it or speed it up I'd love to know.

 

Share this post


Link to post
17 hours ago, luckman212 said:

Right now, I'm using Run NSAppleScript (cached) for this.

 

Why the activate in the code?

 

17 hours ago, luckman212 said:

Is there a faster, better or more efficient way?

 

Use a File Action Trigger.

 

17 hours ago, luckman212 said:

AppleScript seems to be going the way of the dodo.

 

Based on what? I doubt Apple will either develop it further or fix existing bugs, but I see no evidence they’ll phase it out soon.

Share this post


Link to post
1 hour ago, vitor said:

Why the activate in the code?

 

Thanks @vitor ...

 

Without activate in there, the choose file dialog opens in without focusing itself, so an extra click is required to bring it to the front before it will accept input (at least on my system).

 

I also have a File Action trigger in my workflow, but that forces me to remember not to press [ENTER] when selecting the file and remember to use [CTRL] instead to trigger the File Actions. It's definitely faster when I can remember these sequences -- but...I often don't 😩

 

1 hour ago, vitor said:

I doubt Apple will either develop it further or fix existing bugs

 

...exactly why I try to avoid using it ! Anyway, for now it seems to be an ok tool for the job.

 

Share this post


Link to post
1 hour ago, luckman212 said:

but that forces me to remember not to press [ENTER] when selecting the file and remember to use [CTRL] instead to trigger the File Actions.

 

I find File Actions far more useful directly from Finder using whatever Selection Hotkey you have set in Alfred Preferences > Features > Actions > General.

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...