mtissington Posted May 27, 2022 Posted May 27, 2022 (edited) I'm trying to get the current folder from Finder and then pass it to a bash script. However the variable has a new line at the end. How do I fix this? (not sure how to show or attache workflow) Apple script (osascript) on run argv tell application "Finder" set currentFolder to (POSIX path of (folder of the front window as alias)) end tell end run then I feed it to an "Args and Vars" -> debug -> script debug is then showing the variable I assigned {query} from the apple script as containing a new line at the end of the path for example "/Applications/ " instead of "/Applications/" Edited May 27, 2022 by mtissington
vitor Posted May 27, 2022 Posted May 27, 2022 4 hours ago, mtissington said: However the variable has a new line at the end. How do I fix this? Connect it to a Transform Utility set to trim white space.
mtissington Posted May 27, 2022 Author Posted May 27, 2022 I think this is a bug introduced with the recent update - it was working correctly. However I found that the following works and is probably more efficient on run argv set bundleID to (system attribute "alfred_workflow_bundleid") tell application "Finder" set currentFolder to (POSIX path of (folder of the front window as alias)) end tell tell application id "com.runningwithcrayons.Alfred" set configuration "path" to value currentFolder in workflow bundleID end tell end run
vitor Posted May 27, 2022 Posted May 27, 2022 3 hours ago, mtissington said: I think this is a bug introduced with the recent update - it was working correctly. It’s not a bug. AppleScript and JXA always return a new line at the end. You can avoid it by using the Objective-C bridge, but the Utility makes more sense. 3 hours ago, mtissington said: the following works and is probably more efficient Highly unlikely. AppleScript itself is slow. Plus, you’re setting a Workflow Environment Variable which affects the Workflow as a whole, which may or not come to bite you. Trimming the output is the cleanest and fastest way (depending on what your Workflow is doing).
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