How do I make a copy backup of an Indeisgn file with a script and rename it?
I know about backing up IDML files, but for large files, I think it would be faster to copy the indd file directly.
I want to copy the current indd file directly to the “Backup” directory in the same level directory and rename it.
Like this:
aa.indd
After the backup:
... \Backup\2025-03-03-aa.indd
Some of the code below is for backing up IDML files and it works fine.
I want to add copy indd file to Backup and change the name .
Please advise how to modify it.
Thanks a lot.
var myDate = new Date();
var myYear = myDate.getFullYear();
var myMonth = ("0" + (myDate.getMonth() + 1)).slice(-2); // Add leading zero
var myDay = ("0" + myDate.getDate()).slice(-2); // Add leading zero
var myFormattedDate = myYear + "-" + myMonth + "-" + myDay;
/**
* Creates a folder inside of the active document’s parent folder
* @ param the active document
* @ return the folder’s path
*
*/
saveIDML();
function saveIDML() {
//creat Backup folder
var myPathName = app.activeDocument.filePath.fsName + '/' + 'Backup';
var mySFolder = Folder(myPathName);
try {
// Create backup folder
mySFolder.create();
var idmlPath = app.activeDocument.filePath.fsName.replace(/\\/g,'/')+'/'+"backup"+'/'+myFormattedDate+"-"+app.activeDocument.name.replace(/\.indd|\.indt/g,'.idml');
app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlPath, false);
}
catch(e)
{
alert("Problem when creating the folder")
}
}
