MacOS – way to extract contents from AppleScript file without using AppleScript editor

applescriptmacos

I have a bunch of applescript files I need to run but some that were running yesterday are not running today. Applescript is showing me this beautiful message.

enter image description here

When this message is shown, console shows this message:
04/06/14 11:32:44,079 xpcd[324]: Info.plist does not contain an XPCService dictionary: /System/Library/Frameworks/Security.framework/XPCServices/SecurityAgent.xpc

The problem is probably with applescript editor, because I have restored several copies of the script with different dates and none opens. Some other scripts open, but not this.

Is there a way t extract the contents of this file to a TXT so I can try to recreate the script?

thanks

NOTE: I have verified now that the scripts are not corrupted by running them from command line using osascript.

Best Answer

You cannot open a .scpt file with any editor! It is a compiled version of the script, not text, and it will not open with any editor.

Case in point, here is what happens when I try to view the file in Terminal...

Viewing compiled applescript

OSX comes with osadecompile that will extract the source code of a compiled script .scpt file.

Here is an example...

$ osadecompile args2.scpt 
on run argv
    set argc to 0
    try
        set argc to (count of argv)
    end try
    display dialog ("Argument Count: " & argc as string)
end run