A snapshot mechanism (of sorts) using custom md fields (inspired by Scrivener)

Warning

  1. 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.
  2. These are potentially destructive scripts. You cannot ⌘Z your way out of changes made by scripts.
  3. Finally, this is intended for markdown and/or plain text.

The idea

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.


Thank you for the scripts! Just wondering whether you saw these smart rules:

Interesting approach.
However, why not be safer and just generate new files for the versions?

Thanks, Chris! I did see it, but I still preferred using a modified version of your old “create version script” that is still floating around somewhere here in the forum. I found it easier to create and restore versions using it.

Thanks, Jim! Maybe I should have mentioned to others reading this not to use this as a backup mechanism. I actually keep several backups of my databases and file folders, not to mention that the bulk of note taking is kept in a folder using the git system (periodically uploaded to a private github repository). This is merely a convenience for keeping quick snapshots (I actually should have called it this: snapshots), as they are three key strokes away from a compare window or one keystroke away from a restore to the original template before any modification (I am heavily experimenting with the transclusion script so I use this frequently).

I actually keep several backups of my databases and file folders, not to mention that the bulk of note taking is kept in a folder using the git system (periodically uploaded to a private github repository).

I would have expected no less from you :slight_smile:

1 Like

I have learned my lesson the hard way :laughing:

IMHO, it will be interesting to combine the concept of @Bernardo_V and @cgrunenberg. The different versions of a file can/should be saved in a separate group. We will only need one group to hold the previous versions of many markdown files because @Bernardo_V can consider using only one cmd for script 1 to hold the UUIDs of all previous versions/snapshot of each file. So, his script 2 is to read all UUIDs in the cmd and being shown as a list for the previous snapshot (in which the number of versions is becoming almost unlimited). Therefore, it combines a “real backup” with the function of instant recall of snapshot and comparison (by BBEdit). Just a thought.

It is an interesting idea. I was using something like this before and I realised I prefer having the snapshots available close by, in the inspector, for glancing over if I need to. For some reason, I also dislike having an excess of unnecessary files polluting the database with several copies of the same record.

Here are the scripts I was using, in case you want to take a look and make your adaptations.

1 Like

A good point particularly the inspector bar can now expand to half of the width and the snapshot and version scripts can work in parallel if the user chooses to do so. :+1: :+1:

1 Like

On an appropriately sized monitor. :wink: