lost content in Script Editor

I have some content saved in Script Editor. They are saved in the 'default' way where I simply CmdQ.

It happened that my laptop ran out of ram, or had some other odd issue, and the contents in the Script Editor would not be saved in that default manner. After restarting the computer, I could not longer find the content when I open Script Editor.

How can I search for the lost content? Where does Script Editor noramlly save its content?


Solution 1:

They are saved in the 'default' way where I simply CmdQ.

In macOS Catalina and macOS Big Sur I do not find that to be the case. If in Script Editor, if I press ⌘Q I'm presented with a Save As dialog box where I have to choose between Delete, Cancel or Save.

Where does Script Editor noramlly save its content?

That said, when Script Editor opens a document, what happens is at ~/Library/Autosave Information/ a file named com.apple.ScriptEditor2.plist is created/updated and a file named Unsaved Script Editor Document.scpt is created/updated. As more documents are created a new document named, e.g., Unsaved Script Editor Document 2.scpt, where the number in the document name is incremented as more documents are created.

Solution 2:

There are three places I can find where this data is stored.

~/Library/Saved Application State/com.apple.ScriptEditor2.savedState
This, in common with most saved state folders, remembers which files were open & their window positions etc. It only does this for existing script files, already saved somewhere on your disk.
~/Library/Autosave Information/com.apple.ScriptEditor2.plist and
~/Library/Autosave Information/Unsaved Script Editor Document
These are responsible for holding the contents of completely unsaved files.

When you Quit & rely on autosave, then completely unsaved files are saved in the Autosave folder, previously saved files have their changes written back to their existing saved file location. This works even if you change the file name beween launches.