AppleScript to export script editor script as application

applescriptautomatorscript

I have a binary that I want wrapped up as an Application, so I thought this was a good use case for AppleScript.

I want to automate how Script Editor lets you export an AppleScript as a .app bundle. This is what I have so far, I'm confused about how to read the libraries dictionary for the script editor.

tell application "Script Editor"

set command to "do shell script " & "\"APP_PATH\""
set innard to {contents: command}
set Tallgeese to make new document with properties innard
save Tallgeese as "application"

end tell

Best Answer

You must specify the full path where you want to save this application.

Here is an example that saves it in the "Applications" folder of the user.

set appName to "someAppName"
set thePath to (path to applications folder from user domain as string with folder creation) & appName & ".app"
tell application "Script Editor"
    set command to "do shell script " & "\"/bin/ls\""
    set innard to {contents:command}
    set Tallgeese to make new document with properties innard
    compile Tallgeese
    save Tallgeese as "application" in thePath
    close document 1 -- close the document
    -- quit ---- quit the editor
end tell