'telling' a specific application by a specific full path using Applescript

Mathieu Tozer picture Mathieu Tozer · Jun 1, 2011 · Viewed 8.8k times · Source

I am looking to tell application "xyz", but by specifying a full path to the application. This is because there may be various versions of the app on the system in different places, but with the same name. If this possible?

Answer

regulus6633 picture regulus6633 · Jun 1, 2011

Have you tried it? It works with either a posix style path or mac style path, so what's the issue? It couldn't be easier.

set posixCalculatorPath to "/Applications/Calculator.app"
set macCalculatorPath to (path to applications folder as text) & "Calculator.app"

tell application posixCalculatorPath to activate

delay 2

tell application "Calculator" to quit

delay 2

tell application macCalculatorPath to activate

One thing that you might not know how to do is to find the path to the application you want to target. I have created a tool found here which, if you feed it the path to a file then it will return the paths to all of the applications that could open that file. So that result would tell you if there is multiple applications with the same name and then you could choose which one to use.