Automator Help: Get item location

Discussion in 'Mac Programming' started by JesseW6889, Feb 25, 2012.

  1. JesseW6889 macrumors 6502

    Dec 12, 2010
    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/
    2. Replace the '/path/' with the path and name of app
    codesign -fs "Cydia Developer" '/Users/jessew/Desktop/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!
  2. chown33, Feb 25, 2012
    Last edited: Feb 25, 2012

    chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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. 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).

Share This Page