WalterBeiter Posted May 4, 2017 Posted May 4, 2017 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
deanishe Posted May 6, 2017 Posted May 6, 2017 How are you running the script? In Script Editor? With osascript? With a Run Script action? With a Run NSAppleScript action?
WalterBeiter Posted May 7, 2017 Author Posted May 7, 2017 I am using an NSAppleScript action in Alfred
deanishe Posted May 8, 2017 Posted May 8, 2017 Try a normal Run Script action with Language = /usr/bin/osascript (AS) instead. You shouldn't use Run NSAppleScript unless you have a very good reason to.
WalterBeiter Posted May 8, 2017 Author Posted May 8, 2017 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.
deanishe Posted May 8, 2017 Posted May 8, 2017 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? WalterBeiter 1
WalterBeiter Posted May 8, 2017 Author Posted May 8, 2017 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!
deanishe Posted May 8, 2017 Posted May 8, 2017 Here's a better way that works regardless of system language: on isFolder(theAlias) return folder of (info for theAlias without size) end isFolder That gives you a simple true/false.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now