Jump to content

applescript behaves differently in Alfred


Recommended Posts

I've got an applescript which opens a specific path in the finder. When implementing this applescript in Alfred it behaves different. 

for instance, setting "q" to "~" (the home directory) will open the folder in the finder. 

But passing "~" in alfred in my workflow as an argument will reveal the folder, not open the folder.

I want it to open the folder, similar to how the go to function in Finder works. Not reveal it. 

In Alfred I am using the Run NSAppleScript action and a keyword with an argument to trigger the script. 

set q to "~"

set folder_var to true

set mypath to q as text

if mypath = "~" then
	set q to "/Users/David"
else if "~" is the first character of mypath then
	set mytext to text 2 thru (count of mypath) of mypath
	set q to "/Users/David" & mytext
end if


set q to (POSIX file q) as alias

if kind of (info for q without size) is not "Ordner" then
	set folder_var to false
end if





if folder_var is true then
	if mypath = "~" then
		set q to "/Users/David"
		set q to (POSIX file q) as alias
	end if
	tell application "Finder"
		activate
		make new Finder window to folder q
	end tell
else
	tell application "Finder"
		activate
		reveal q
	end tell
end if

 

Link to comment

Thanks for all the input, so far, the behavior has not changed.

It reveals the folder instead of going into it. But running the exact same script (without the "on alfred_script (q)" part) makes the Finder go into the folder. 

The script should go into the folder, but reveal if the given argument is a file.

 

Link to comment
3 minutes ago, deanishe said:

Bit of a long shot, but it may be due to Alfred being English. 

 

It appears that your script checks whether the type is "Ordner". Have you tried using "Folder" in Alfred?

 

Yep that was it. Thanks a lot. Solved my problem!

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