View Full Version : Automator Help: Get item location

Feb 25, 2012, 03:08 PM
I've got some programming background but don't quite know my way around automator. I am a iOS application developer, and I test my apps on my jailbroken iPhone, but they need to be code signed first, which consists of running a command in terminal to the location of the .app file, which is kind of a pain in the butt, but this is my routine now...

1. Copy and paste this script into terminal:
codesign -fs "Cydia Developer" /path/appname.app/appname

2. Replace the '/path/appname.app/appname' with the path and name of app
codesign -fs "Cydia Developer" '/Users/jessew/Desktop/Switch Views.app/Switch Views'

3. Execute

How would I automate this, by say, dragging and dropping the file or (preferably) the folder and have automator copy the location and append that to the 'codesign -fs "Cydia Developer"' code. It seems like it should be pretty easy, but I don't know how to do it!

Any help would be MUCH appreciated, its a pain in the butt to do EVERY time I want to try an app on my phone... thanks!

Feb 25, 2012, 04:27 PM
Since you already know how to write shell scripts (or so it seems), you can simply wrap a shell script into a drag-n-drop wrapper, like Platypus (http://sveinbjorn.org/platypus). You have to put a little code at the head of the script, to accept the dropped items as normal command-line parameters, but after that it's just like a normal shell script.

Here's an example I use:

#printenv | sort

## Under Platypus, $1 is path to app-bundle.
## MUST NOT process that.
## Relies on env-var APP_BUNDLER being set to "Platypus*"

if [[ "${APP_BUNDLER:0:8}" = "Platypus" ]]
echo ".. Platypus at: $APP_DIR"

# This script strips all ".DS_Store" files from a subtree.
# This is most often useful on app-bundles.

# echo "$@"

for item in "$@"
if [ -d "$item" ]
echo "Directory: " "$item"
find "$item" -name ".DS_Store" -print -delete


The original script I developed starts at the "This script strips all ..." comment. The preface is boilerplate I use in several Platypusified scripts, for detecting that they're running under Platypus. If it's not obvious, I have the APP_BUNDLER env-var set under Platypus, but NOT set in my normal Terminal shell (unless I'm testing it in an environment like Platypus).