Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Running an application with arguments through applescript...

Hi there,


I'm just starting to get my head around AppleScript and I was hoping someone could help me get started on this.

I'm just trying to launch an application with arguments and im having a little trouble.

Firstly I'm not sure how I'd get the actuall path to the application to run...

(Also I'm not sure how you would apply the arguments but just getting it to run would be nice as a start.)


If anyone could help, it would be great!


Thanks,

Pete

macbook pro

Posted on Feb 15, 2013 10:06 PM

Reply
Question marked as Best reply

Posted on Feb 16, 2013 2:31 AM

You don't find the path as such, you refer to it by its bundle identifier.


In Applescript, first use


get id of application "name"


where you replace name with the app's common name. In the results of the editor you'll get something like


"com.something.name"


(you may get asked to locate the app visually first through a Finder-like window). That's the bundle identifier. You then use that with 'id' in your commands instead of a path, like


tell application id "com.something.name" to activate

16 replies

Jun 18, 2015 6:38 AM in response to peterleary

peterleary wrote:


So I created the subl symlink it using

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl


Now my applescript looks like this - do shell script "/Users/Pete/bin/subl /Users/Pete/bin/test.txt"

And that seems to work great for a start



If you're using do shell script, you can also use the Terminal open command with -a (see man open for other options and examples).


do shell script "open -a Sublime\\ Text\\ 2 /Users/Pete/bin/test.txt"

Running an application with arguments through applescript...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.