Mathieu Tozer
Mathieu Tozer

Reputation: 278

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

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?

Upvotes: 18

Views: 9930

Answers (2)

1.61803
1.61803

Reputation: 433

launch application ":Applications:TextEdit.app"

tell application ":Applications:TextEdit.app" to launch

Upvotes: 7

regulus6633
regulus6633

Reputation: 19030

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.

Upvotes: 19

Related Questions