- Do not use this as a backup mechanism. These snapshots should be considered a convenience. It was not intended to protect from loss of data. There is no safety net here.
- These are potentially destructive scripts. You cannot ⌘Z your way out of changes made by scripts.
- Finally, this is intended for markdown and/or plain text.
The idea is very simple. I created custom metadata fields to store snapshots of the text (v1-v9) and the modification time (d1-d9).
I keep it at the bottom, so I don’t see it if I don’t want to.
The first script: Save Snapshot
The first script is for storing the text. It will store the current text in v1 and throw what was in v1 to v2, what was in v2 to v3 and so on. What was in v9 says goodbye.
The second script: Compare/Restore Snapshot
The second script is for restoring a snapshot. When it is activated, it will ask whether you want to compare snapshots using BBEdit (could have used filemerge or something else, but I like BBEdit and you can install it for free) or simply restore to one of the previous snapshots.
The next dialog will prompt for the desired snapshot to be compared or restored.
If you chose to restore, that’s it. The script will do so by replacing the text of the record by the stored snapshot and it will log the change in DEVONthink (I like how discrete the log is and prefer it over the notification function). If you chose to compare instead, you can make the changes you want and then save.
Here is the compare window open in BBEdit.
A third little script - Restore Directly to v0
Side-note: I am also keeping a v0, which is sort of a template for the note and which won’t be touched by the first script. I also set up a special shortcut to restore directly to this snapshot without any prompts. This will be the third script.