10

Is there a way to compile an an applescript from the command line similar to the following. enter image description here

14

The answer to this is surprisingly simple:

$ osacompile -o output.app input.applescript

This works for both plaintext .applescript files and the .scpt files that Script Editor makes.

You can use a pipe too, e.g. if you have the script on your clipboard:

$ pbpaste | osacompile -o output.app

Or -e, like the osascript command can use:

$ osacompile -o output.app -e "$(pbpaste)"

You can also use JavaScript with the -l flag:

$ osacompile -o output.app -l JavaScript -e 'app = Application.currentApplication();' -e 'app.includeStandardAdditions = true;' -e 'app.displayDialog("hi");'
1
  • The command in 0942v8653's answer will place the app in your current working directory—which, by default, is your home folder. If you need to specify the location in which the app will be saved, do something like this: ``` osacompile -o /Users/yourUsername/Desktop/aFolder/test.app -e "say \"Hello, there\"" ``` – Peter Schorn Jan 5 '20 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .