Jump to content

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

Link to comment

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
Link to comment
  • 4 weeks later...
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.

Link to comment
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.

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