Copy link to clipboard
Copied
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")
}
}
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;
saveBackupFiles();
function saveBackupFiles() {
var doc = app.activeDocument;
var docPath = doc.fullName.fsName.replace(/\\/g, '/'); // Get .indd file path
var backupFolderPath = doc.filePath.fsName + '/' + 'Backup';
...
Copy link to clipboard
Copied
Why not simply package the file and rename the file? Why do you want a script?
Copy link to clipboard
Copied
Oh my God.
Why are you packing? Nothing to do ......
The only time you need to pack is when the client is about to confirm the final draft.
Or if you're working on a different computer, you need to pack.
Copy link to clipboard
Copied
When you run Package - you can untick fonts/links copying, PDF creation - select only IDML creation.
Copy link to clipboard
Copied
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;
saveBackupFiles();
function saveBackupFiles() {
var doc = app.activeDocument;
var docPath = doc.fullName.fsName.replace(/\\/g, '/'); // Get .indd file path
var backupFolderPath = doc.filePath.fsName + '/' + 'Backup';
var backupFolder = Folder(backupFolderPath);
try {
// Create Backup folder if it doesn’t exist
if (!backupFolder.exists) {
backupFolder.create();
}
// Save IDML file
var idmlPath = backupFolderPath + '/' + myFormattedDate + "-" + doc.name.replace(/\.indd|\.indt/g, '.idml');
doc.exportFile(ExportFormat.INDESIGN_MARKUP, new File(idmlPath), false);
// Save INDD file with new name
var inddBackupPath = backupFolderPath + '/' + myFormattedDate + "-" + doc.name; // Modified INDD name
var inddFile = new File(docPath);
var inddBackupFile = new File(inddBackupPath);
inddFile.copy(inddBackupFile); // Copy the INDD file
} catch (e) {
alert("Problem when creating the backup: " + e.message);
}
}
Copy link to clipboard
Copied
HI Eugene Tyson
Thank you, you are the God of my heart
Copy link to clipboard
Copied
If it works for you can please mark as correct answer, or if you need something else let us know.
Copy link to clipboard
Copied
Sorry ~
I forgot it.
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now