Getting Current Working Directory

Scripts run via a Platypus wrapper will run with the filesystem root ("/") as the current working directory ($PWD). The following is a small demonstration of how to make the directory containing your Platypus-created application the current directory.

#!/bin/sh

cd "$1/.."
echo $PWD
mkdir TestDir

Wrappping this shell script with Platypus will create an application that creates a directory called "TestDir" in the same directory as the application itself. The $1 variable contains the path to the application folder itself (i.e. /the/path/to/theApp.app). The following code cd "$1/.." will change the current working directory to the directory containing the application.


©2004 Sveinbjorn Thordarson