Automatically compile or sync to external folder upon "Save"

I’d like Scrivener to automatically and quietly compile or sync to an external folder in the background whenever I save. Alternatively I’d like to trigger an AppleScript, Shell command or anything else upon save.

Any ideas on how I could accomplish this?

If you’re mainly just looking for a way to create an extra backup whenever you hit Cmd-S, you could enable the “Back up with each manual save” option in the Backup preferences tab. If you’ve never adjusted these before, you may find some other options here that you want to tweak. I like to push the number of saved backups as high as possible, for example.

Otherwise the best solution would be to automate from the outside and trigger both the save and the compile in a single script, rather than having a script triggered from a save. The main problem will be getting around Compile’s interactivity. I have a script for Keyboard Maestro that will trigger a compile, execution of that compile, and force overwrite of any existing older compiled files with a single command. So it wouldn’t be hard to throw a Cmd-S at the top of that procedure to combine the two together. If you use KM, I posted that script, here.