Jump to content
gustavok

Apple Script to open a folder PROBLEM

Recommended Posts

Hi, 

I made a simple an apple script to open a specific folder triggered by a hotkey, but it's not working and I can't find why.

It works if I use the Script Editor from Mac OS but when I paste it inside the   "Run NSAppleScript" window on Alfred it doesn't. 

 

Script:

 

on alfred_script(q)

 

 property the_path : "/Users/UserXXX/Downloads"
 set the_folder to (POSIX file the_path) as alias

 tell application "Finder"
    activate

    if front Finder window exists then
      set target of front Finder window to the_folder
    else
      open the_folder
    end if

 end tell

 

end alfred_script

Share this post


Link to post

Just out of curiosity: Why not just have Alfred open the folder with the "Open File" action?

 

In a new workflow:

Add a Hotkey and set it to whatever you want.

Add an "Open File" action and drag the folder you want to open into the left pane of the popup, where it says "Open the passed-in file(s)"

then save

Then, connect the hotkey to the open file action.

Edited by RodgerWW

Share this post


Link to post
On 11/18/2016 at 1:56 PM, RodgerWW said:

Just out of curiosity: Why not just have Alfred open the folder with the "Open File" action?

 

In a new workflow:

Add a Hotkey and set it to whatever you want.

Add an "Open File" action and drag the folder you want to open into the left pane of the popup, where it says "Open the passed-in file(s)"

then save

Then, connect the hotkey to the open file action.

Thanks ! It works. I thought that the "open file" action only work with files and not folders. Anyway, I'm curios why the commands didn't work on that script.

Share this post


Link to post
9 hours ago, gustavok said:

Thanks ! It works. I thought that the "open file" action only work with files and not folders. Anyway, I'm curios why the commands didn't work on that script.

 

Well, not sure why the "Run NSAppleScript" does NOT work, but:

Change the "Run NSAppleScript" to a "Run Script" Action.

Then in the script language, change to "/usr/bin/osascript (AS)".

Then for the script, remove all text that is already there, and then place your script from above into the blank area.

That works for me fine here.

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