• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to set automatic backups to specific folder in InDesign

Community Beginner ,
Aug 28, 2014 Aug 28, 2014

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;

}

TOPICS
Scripting

Views

12.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 29, 2014 Aug 29, 2014

Remove this line: var myFolderName = 'Backup';

Replace this line : var myPathName = myDoc.filePath.fullName + '/' + myFolderName;

with : var myPathName = "Z:/backup";

Regards,

Chinna

Votes

Translate

Translate
LEGEND ,
Aug 29, 2014 Aug 29, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

dead link…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 14, 2023 Mar 14, 2023

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2014 Aug 29, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 31, 2014 Aug 31, 2014

Copy link to clipboard

Copied

Thanks a lot. That did the trick for the direct path location.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines