Copy link to clipboard
Copied
The following script saves a copy of an InDesign file to a set folder in the same location of its file being backed up.
Question: How can I edit the script to save the backup file to a specific path? For example, to a network drive (Z:/backup). Which line in the script should be changed?
Much is appreciated.
//saveVersions.jsx
//DESCRIPTION: Saves the active document versions in a numbered loop
#targetengine "session"
var myEventListenerVersions = app.addEventListener("beforeSave", SaveVersion);
function SaveVersion()
{
var myFolderName = 'Backup';
var myDoc = app.documents.firstItem();
// Create Backup only if the document has already secured after production
// (That exists as a file on a disk)
if (myDoc.saved == true)
{
var myCounter = getVersion (myDoc); // Refers version number; this is re-set if required
var myPathName = myDoc.filePath.fullName + '/' + myFolderName;
var mySFolder = Folder(myPathName);
try {
// Create backup folder
mySFolder.create();
}
catch(e)
{
alert("Problem when creating the folder")
}
// Create version copies
var myName = setVersionName(myDoc.name, myCounter);
File(myDoc.fullName).copy(myPathName + "/" + myName);
}
}
function getVersion(aDoc)
{
if (myMax = aDoc.extractLabel( 'theMax' ))
{
// version number
myVersion = aDoc.extractLabel( 'theVersion' )
}
else
{
// version number
do
{
// Prompt max. version number
myMax = prompt ('Maximum Versions:', 5);
if (myMax == null)
exit();
} while (myMax < 1)
myVersion = '0';
aDoc.insertLabel( 'theVersion', myVersion);
aDoc.insertLabel( 'theMax', myMax);
}
// Sichern der Versionsdaten
myNewVersion = setVersion( aDoc, [myMax, myVersion]);
return myNewVersion;
}
function setVersion( aDoc, aData )
{
myNum = Number( aData[1] );
(myNum >= Number( aData[0] )) ? myNum = 1 : myNum++;
aDoc.insertLabel( 'theVersion', String( myNum ) );
return String( myNum );
}
function setVersionName(aName, aCounter)
{
var myIndex = aName.indexOf( '.indd');
if (myIndex == -1)
{
var theNewName = aName + '_' + aCounter;
}
else
{
var theNewName = aName.substring(0, myIndex) + '_' + aCounter + aName.substring(myIndex, aName.length);
}
return theNewName;
}
Remove this line: var myFolderName = 'Backup';
Replace this line : var myPathName = myDoc.filePath.fullName + '/' + myFolderName;
with : var myPathName = "Z:/backup";
Regards,
Chinna
Copy link to clipboard
Copied
Hi,
I've not tested your script but do you know the script written by Peter Kahrel?: Free script Batch convert/export InDesign documents | Peter Kahrel
Copy link to clipboard
Copied
dead linkā¦
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi @Alastair L , I just posted a pair of auto save scripts in this thread:
https://community.adobe.com/t5/indesign-discussions/indesign-autosave-file/td-p/9191135
Copy link to clipboard
Copied
Remove this line: var myFolderName = 'Backup';
Replace this line : var myPathName = myDoc.filePath.fullName + '/' + myFolderName;
with : var myPathName = "Z:/backup";
Regards,
Chinna
Copy link to clipboard
Copied
Thanks a lot. That did the trick for the direct path location.