Can an Automator Workflow/App Find Itself?
September 3, 2008 12:06 PM   RSS feed for this thread Subscribe

Obscure Mac geekery filter... On OS X Leopard, how can I get a reference to the current location of an Automator workflow/app in a shell script within that workflow?

I've got a complex Automator workflow that currently has to move files in and out of various directories. Currently these directories live in a specific location that's hard coded into the workflow. What I'd like to do is have the workflow be able to reference it's own package and create the directories it needs inside itself (ex. /some/random/path/myworkflow.workflow/Contents/niftyFolders) or, barring that, just create the directories in the same directory the workflow itself is currently in. Unfortunately I can't find a way to get the location of the workflow itself.

I'm thinking the most likely way to do it at this point is with AppleScript, and I've looked into that a little, but have come up empty. AppleScript and I have never clicked, so I thought I'd turn to all of you.

Thanks!
posted by Xuff to computers & internet (3 comments total)
I'm not sure. Does this help?
posted by I_pity_the_fool at 1:00 PM on September 3, 2008


The AppleScript command "path to me" will return the path to the executable that runs the script, but within an automator action, that executable is Automator.app, not the workflow itself. As I'm sure you've surmised, there's no built-in way to return the path to a workflow. The workflow itself doesn't even show up as an open file when I try "lsof" from the command line, so using a shell script is pretty much out.

What's your requirement or need for getting the path to the workflow? Can you not count on it always being in the same place? Also, are the folders you'd like to create within the workflow itself temporary? If so, I'd just use /tmp.
posted by pmbuko at 1:43 PM on September 3, 2008


You're both awesome! pmbuko, you're correct that path to me returns Automator.app, but if you save the workflow as an application the path returned is, indeed, that application!

Absolutely wonderful, thank you!
posted by Xuff at 1:56 PM on September 3, 2008


« Older I'm trying to locate a print o...   |   Roadtrip filter: Driving from ... Newer »
This thread is closed to new comments.