/AppleScript: Current Directory

AppleScript: Current Directory

I wanted to create an AppleScript to launch a shell script. The problem I ran into is whenever I do a shell script the working directory is my home directory. I need to find out a way to change the directory to the current directory.

With the help of this book and some hints I googled, I finally found the correct combination. Here is the code.

tell application "Finder" to get folder of (path to me) as Unicode text

set workingDir to POSIX path of result

The code stores current directory in variable workingDir in POSIX format. You can then use it in your shell script.