3

If I have an applescript snippet such as this

tell application "Finder"
set thePath to (POSIX path of (path to application "MyApp"))
end tell

it will return to me

"/Applications/MyApp.app"

Now, what I can't seem to figure out is how to instead specify "MyApp" via a variable rather than the literal.

My applescript reads in some XML values, one of them being the name of the application I'm interesting in. I've tried this:

tell application "Finder"
set thePath to (POSIX path of (path to application someVariable))
end tell

but this simply tells me the error

"Finder got an error: Can't make application "MyApp" into type constant."

Any ideas how I can do this?

1 Answer 1

4

The answer (or at least one answer) is:

set theApp to "MyApp"
set pathToTarget to POSIX path of (path to application theApp)

Since path to application is a part of Standard Additions, the Finder is not needed.

Thanks to Stephan K on MacScripter for setting me straight on this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.