Vivien Posted October 14, 2013 Posted October 14, 2013 Hello, I hope my question is not yet asked somewhere else. So, I've just created a simple and straight forward workflow to make a folder tree. It works fine when interpreted in terminal, but in Alfred the tree is created into the workflow folder. I've seen here that the relative path is always the path trelative to the workflow folder. My question is probably noobish but… how can get the path of the folder I'm in at the time I launch Alfred to make my request ? Any hint would be appreciated.
vitor Posted October 14, 2013 Posted October 14, 2013 You can do it with Applescript (to run applescript inside your bash script, use osascript -e "<code here>"). -- with this method -- if a Finder window is the frontmost window, it’ll return the path to it, else it’ll return the path to the desktop tell application "Finder" to set dirPath to (quoted form of POSIX path of (insertion location as alias)) return dirPath -- with this method -- if there’s any Finder window open, it’ll return the path of the frontmost one, else it’ll return the path to the home directory try tell application "Finder" to set dirPath to (POSIX path of (folder of the front window as alias)) on error set dirPath to (POSIX path of (path to home folder)) end try return dirPathYou can see this workflow for a working example.
Vivien Posted October 15, 2013 Author Posted October 15, 2013 Thanks a lot Vítor. It works perfectly. I didn't want to use applescript because my last workflow used it and it was a pain, but since it seems I have no choice… :-) Thanks again.
vitor Posted October 15, 2013 Posted October 15, 2013 I didn't want to use applescript because my last workflow used it and it was a pain. I know the feeling — a mix between “I hate this” and “at least there’s some way to do it”.
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