Automator use current directory location
Solution 1:
Have your workflow figure out its own path (more robust)
This works as long as your Automator workflow lives in the same directory as MyApp.app
; you can create copies of either the workflow or the app at your discretion and reuse those copies wherever you want; nothing needs to be unique.
Steps
These are the steps to automate launching MyApp.app
:
Open the workflow in Automator.
-
Add a Run AppleScript action. Remove all the boilerplate code inside and replace it with the following lines:
set AppleScript's text item delimiters to ":" set appPath to (text items 1 through -3 of (path to me as text) & {"MyApp.app"} as text) tell application "Finder" to open file appPath
Save the Automator workflow in the same folder as
MyApp.app
.Run the Automator workflow; it should launch
MyApp.app
.
Explanation
set AppleScript's text item delimiters to ":"
This means “Watch out, I’m going to split a string soon; and I want you to use the :
character as the split boundaries.”
path to me as text
This instructs the workflow to figure out the path to itself; path components are delimited by a colon (:
), which is a remnant of Classic Mac OS.
text items 1 through -3 of […] & {"MyApp.app"}
This cuts off the last part of the path, and appends MyApp.app
to the path.
[…] as text
This pieces the path back together (again with :
as a delimiter).
tell application "Finder" to open file appPath
Lastly, this final line causes MyApp.app
to launch.