InDesign_save_with_backup

04/08/2021 By admin@billgreenwood.co.uk





The script below allows you to save a copy of an indesign file in a folder names backup which will be situated on your desktop. You can always edit the script to save the backups in a folder eslewhere on you computer.

Copy the text and save it as a .JSX text file. Store this in your scripts folder. My files is called “Save with backup.jsx” and is in this path on my mac.

/Users/billgreenwood/Library/Preferences/Adobe\ InDesign/Version\ 16.0/en_GB/Scripts/Scripts\ Panel/save\ with\ backup.jsx



//DE//DESCRIPTION:Copies the current document to a backup-location before saving
var desktop_path = Folder.desktop.toString();
var backup_path = “/Users/billgreenwood/Documents/INDESIGN_BACKUP”;
//var backup_path = desktop_path+”/backup”
if (Folder(backup_path.exists == false )) {
Folder(backup_path).create();
}
if (app.documents.length > 0) {
main();
}

function main() {
var doc = app.activeDocument;
try {
if (doc.saved == true) {
var doc_file = doc.fullName;
var doc_name = doc.name;
var now = new Date();
var datestamp = now.getFullYear().toString() + ” ” + two_digit(now.getMonth()+1) + ” ” + two_digit(now.getDate());
var timestamp = two_digit(now.getHours()) + two_digit(now.getMinutes()) + two_digit(now.getSeconds());
var target_folder = Folder(backup_path + “/” + datestamp);
if (target_folder.exists == false ) {target_folder.create(); }
var target_file = target_folder.toString() + “/” + timestamp + “_” + doc_name;
if (doc_file.copy(target_file) == false) {
alert(“Backup error\rCould not create backup copy.”);
}
}
} catch (e) {
alert(e);
}
doc.save();

function two_digit(n) {
    if (n < 10) {
        return "0" + n.toString();
    } else {
        return n.toString();
    }
}

}



I have assigned the script a keyboard command. ⌘ S

I did this so every time I save the file, a copy of it is stored elsewhere. It has helped me out quite a few times.







Here are some links on InDesign recovery files
https://creativepro.com/never-more-than-a-minute/
https://www.easeus.com/mac-file-recovery/indesign-file-recovery-on-mac.html