17.9.14

Repair corrupt AppleScript .scpt files stored on non-Mac media

Problem: When opened in Script Editor or AppleScript Editor, file displays ASCII garbage instead of human-readable text.  The garbage might begin with "FasdUAS".  This occasionally occurs when the AppleScript .scpt file is saved on non-Mac media, such as a central server or a NAS device.  I don't understand why this occurs, but it has happened to me enough times (on a couple Windows servers and on a NAS) that it seems like a real problem.  It might have something to do with incompatibility between the antiquated resource/data fork file structure of AppleScript files and hard drives that are not formatted for Mac OS.  I really don't know.

One solution: Always save AppleScripts on Mac OS formatted media.  Fat lot of help that is when the script you've been working on for days is suddenly trashed.

Another solution:  Make a copy of your corrupt file.  Open up the copied file with a hex editor.  There are many; I use Hex Fiend.  AppleScript .scpt files begin with the ASCII signature "FasdUAS".  Look for this in the ASCII panel of the hex editor.  The corresponding hex signature is "46 61 73 64 55 41 53".  Delete any text or hex before these signatures.  Likewise, .scpt files terminate with the hex signature "FADEDEAD".  Look for that termination signature in the hex panel of the editor.  Often times  a bunch of "00 00 00 00 00 00" will have been added after "FADEDEAD" for some inexplicable reason.  Delete those or anything else that comes after.  Save the file.  Open in Script Editor.  It may work.  This approach can also be used to recover AppleScripts from byte-level copies of damaged hard disks made using dd or ddrescue.

1 comment:

  1. I had this problem, but unlike your suggestion, there were no extra characters preceding the "FasdUAS " -- the solution to recovering these files was a bit bizarre: use Spotlight to 'find' the script and it is displayed correctly. From there I was able to copy the compiled script and paste it into a new script.

    ReplyDelete