Auto-Snapshots

One more for now…

There might be a feature like this already that I missed, but I don’t think so.

I’m a little lazy and while I know it’s simple to just do a snapshot every time you’re about to edit a file, I think it would be nice if this were automated. For example, when you open any particular file, it should check to see if the last snapshot is identical to the current version. If not, it should take a snapshot of it.

Another possibility would be to do this for all files when you either launch or quit Scrivener.

A third option would be to do this only once you start editing a file. For example, I start typing a new paragraph, it quickly checks what the file was like BEFORE I started typing and compares that to the most recent snapshot. If they’re different, it updates.

This way you would always have up-to-date snapshots without having to do it manually.

This would, of course, be an option.

Conceptually, this might blur the distinction between auto-save and snapshots. The way it works now, Scrivener has your back while you work. If the program crashes or the power goes off, your probably only out of five or ten seconds of work – if that. And for all of those times when I consciously want to create a divide, there are snapshots. Automatically creating them would remove that conscious act. Yes, I would have versions instead of a seamless present that auto-save gives you, but my consciously chosen snapshots would become dilluted and potentially lost in the automation. Consider: Any smart auto-save system that creates distinct copies must have a limiter somewhere. Otherwise, two years down the road you’ll have users with 3,500 versions of each file wondering why their project files are so massive. So if you set a limiter (even user specified), eventually the automation is going to push your manual snapshots off the grid. This would cause one to have to use work-arounds to get conscious divisions. Duplicates in the project, full project backups, and so forth.

Good point, but this could be addressed. For example, have manual snapshots and auto-snapshots in different tabs on the snapshots page. Manual ones are never deleted automatically, while automatic ones are purged occassionally as time goes on (if you set that option)?

Yeah, something like that would solve the “blur.” I wonder if a single list with bolded snapshots might be easier to manage, where bold snapshots are user created, and never deleted automatically.

Something to consider is that, while still off a bit in the future, Leopard will ship with something very nearly just like this, that works on all files in the system. Since Scrivener is a bundle of files, it would probably be very easy to make it work on a sub-project level of granularity.

I’d like to re-open this discussion, especially as snapshots has become more integrated into the Scrivener editor. Although I usually take a snapshot when I start revising a particular document, I sometimes forget. Going back to a backup is cumbersome and tredious, and using Time Machine (the feature of Leopard that I presume Ioa referred to earlier) is even more tedious. :slight_smile:

A prefernce item to automatically generate a snapshot upon revising a document would be nice. If I were designing it, it would only automatically take a snapshot either (1) the first time an edit was made since opening the document in the active editor pane, or (2) when switching to another document in the active editor pane. I can see an incidence where one might make some changes to the document, and undo them. Perhaps only an automatic snapshot when the current editor’s contents have changed since the last snapshot (or take one if there is no previous snapshot)?

I was going to propose something along the lines of auto-snapshots when I found this thread and relatively recent comment.

Autosnapshots would be very useful in my opinion. It’s much better to go back to snapshots than to backups and because of the different keystroke I don’t have the habit of saving snapshots regularly.

One problem is that snapshots may pile up endlessly. A scheme of dropping autosnapshots based on age would be great…

Thanks!

As you note, snapshots would keep piling up; and dropping them based on age wouldn’t make sense - you might end up with dozens of snapshots taken recently when you changed only a single letter and lose a first draft that you later realise was better and now no longer have.

Sorry, but there are no plans for auto-snapshots as it could swell project size and clutter things up horribly. I don’t think cmd-5 is too difficult to hit when you’re embarking on a big edit. :slight_smile:

All the best,
Keith

I would like to reopen the issue again, because I’m searching for a software which is capable of documenting the process of writing for my bachelor’s degree. The snapshot feature seems very promising because you could compare the different shots and see the differences. For the sake of the experiment it is necessary to not to interrupt the author while thinking and also to take shots in a specific time interval. Is there a way to achieve this?

I have been thinking about this since Keith’s response. I think he is right. The auto snapshot has the possibility of snapshots building up over time, and becoming unwieldy. As a developer, any feature that creates potential problems in the software’s operation is a potential problem of support and development. So it’s best to avoid these things.

I have been using manual snapshots before I embark on any major edits and it has worked well for me.

But, thinking about whether this could be done, I took a couple hours and wrote the attached Applescript. I make no warranty as to its usefulness, and if you set the snapshot interval to every second and it fills your project up with snapshots and causes Scrivener to crash or the project to become corrupt, that’s your problem, not mine nor Literature and Latte’s. But I think if you use a reasonable interval, it shouldn’t be too much trouble, and may even help you. But again, I really think manual snapshots are the way to go for most of us.

It will run in the background (sortof), and every so often (based on the interval you select when you run it), if Scrivener is the frontmost (active) application, it will issue the menu commands to take a snapshot. It only takes a snapshot when that menu item is available (i.e. when the text editor is active, not for example the binder). It will also quit itself when Scrivener is no longer running (after the snapshot interval has expired).

You would download the script to a place of your choice, and run it by double-clicking. The Scrivener project should be open before running the script.

You also need to make sure the “Enable access for assistive devices” box is checked in the Universal Access panel of System Preferences.

If you have trouble with the script, you can send me an email danaleighton {at} fastmail {dot} fm but I’ll make no promises that I will have time to debug it. If L&L changes Scrivener’s menu options, it might mess it up too… :slight_smile:

NOTE: The script attached to this message has been superseded by a new version (1.10). See the new version in this reply: http://www.literatureandlatte.com/forum/viewtopic.php?p=97313#p97313
ScrivSnap.app.zip (36.8 KB)

Works like a charm. Thank you very much. The only thing I would complain about is, that the script only works in window mode and not in fullscreen. Also there is this annoying snapshot sound but it can be muted via the system sound volume.

This script is similar to my “Backup every hour” script

dl.dropbox.com/u/1844583/Scriven … n_1_0.scpt

Mentioned here (Scripts pasted into this post are out of date)

https://forum.literatureandlatte.com/t/automatically-back-up-every-n-minutes/11813/1

I too found sending a menu command to Scrivener didn’t work in full screen, so changed my script to send a keyboard command instead.

Here’s a snippet from my script.

[code]if appIsRunning(“Scrivener”) then

tell application "Scrivener" to activate
tell application "System Events" to keystroke "s" using {command down}

end if[/code]

Altering the script to send a command 5 should fix the fullscreen issue.

I also use Lingon (Available on the app store) to run my script every minute, it then has activity and idle checks so it only creates backups when I’m writing and stops when Scrivener isn’t running or has been idle for a given time value.

Thanks Jen. I modified the script and it now uses the keystroke combination instead of the UI. Therefore, for this version, my instructions above to turn on access for assistive devices are unnecessary.

It now works in both regular window mode and full screen mode.

Note that this script (as well as the original above) may cause you to lose a character or more (depending on how fast you type) if the snapshot is taken while typing. It may be in your interest to check your screen when you hear the snapshot sound.

As before, no warranty for fit or function. You may modify or distribute freely.
ScrivSnap1.10.app.zip (33.9 KB)

This is a very interesting route. I reused Yenny_Y8S’s script, activated at regular intervals via Lingon and using the frontmost application, so I’m now having snapshots at regular intervals—thanks a lot!

I wonder two things:

  1. Does anyone know if it’s possible to check when the document in the frontmost scrivener window has been last modified, and execute a snapshot, backup only if the document changed? I can get the file name and path, I guess with some effort I can get the modification date, but the modification date of the .SCRIV package is not the same as the last time any component of it has been modified. I guess what I’d need to do is something like (in natural language): if any RTF file in the Docs folder of the package changed in the last X hours, then tell scrivener to take a snapshot/backup.

  2. Is additional scripting support in the roadmap? I remember Keith asking for suggestions about script uses. In this case the ability to retrieve the list of snapshots of the current element being edited and being able to delete one of them via script. This way it’d be possible to script the mechanism that I proposed before (autosnapshot at X interval, retain the newest Y autosnapshots).

Thanks!

Yes, it’s still on the roadmap but delayed. I was originally hoping to focus on this for 2.1, but 2.1 will be out soon with lots of cool refinements but still no AppleScript support - hopefully for 2.2 instead though. It’s a massive job so will take a large commitment of time.

All the best,
Keith

Thanks for responding, Keith. I certainly understand it’s a major undertaking, and I guess you’d implement it incrementally. In any case, the two solutions pasted here work very well.

Probably so. The biggest job will be designing the initial suite - how to break it up and what goes where. It’s essentially like designing a whole new UI - a UI rather than a GUI - and given Scrivener’s depth, just sketching out the bare bones is design job in itself. And I also have to take time to get myself familiar with how it all works - I don’t really know much AS myself, and on top of that I have to try to decipher Apple’s documentation on implementing AS, which gave me a massive headache last time I looked at it. :slight_smile:

You could theoretically parse the .scrivx XML and look at the “Modifed” attributes but it’s a lot of work to code and QA, which is why I settled for a simple idle check.

I very much support the idea of auto-snapshots, though they couldn’t possibly be as frequent as people are suggesting here. Why not daily, and only if a given document has changed? The process could be as follows:

  1. ACTIVATE:
    ——On first document open of the day, if document was closed.
    ——On first window activation, if document was open.
  2. SNAPSHOT:
    ——Iterate documents matching project preferences. (Toggle “Only draft” vs “All”.)
    ——If it’s been changed since the last snapshot, snapshot again.
    ——Name ‘Auto-Snapshot’.
  3. CLEAN UP:
    ——If there are more snapshots named ‘Auto-Snapshot’ than project preferences limit, delete the oldest.

This allows a user who wants to preserve a specific snapshot to name it.

Some of what you’re suggesting can be achieved with just one simple user intervention. In Preferences > General > Saving, you can enable ‘Take snapshots of changed text documents on manual Save’. (Emphasis mine). So when you invoke Command-S, you get a snapshot of every document in the project that has been altered since your last manual save. If done only at the end of each writing session, you effectively get

More granular snapshot management can be achieved using the Snapshots Manager, though I haven’t explored that feature much yet so can’t comment on how it might work for you.

yeah i would desperately love this feature, as every manual solution is pretty suboptimal. i have adhd and remembering to CTRL+S or CTRL+5 every time i edit something is about a thousand light years beyond me. i set up an autohotkey script but that’s still very far from ideal. this seems like such a basic but incredibly useful feature to me but i guess other writers have flawless memories and habits or something? i feel like that’s not something writers are known for, but i could be wrong.

Mike’s solution above seems pretty perfect to me, though i don’t know why they “couldn’t possibly” be as frequent as people are suggesting if there’s an option to limit the auto-snapshots and differentiate them from manual ones. i have a 250GB hard drive in my laptop and about 2 of those are used by my writing software + all my writing and reference materials for the past two decades, so i’m not super worried about a few thousand more text files lol