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

Error in script to relink in Indesing

New Here ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

Yesterday  I was given a script that relinked in Indesign so fast - and I have used  numerous times yesterday and today.

BUT al of a sudden it gives me a java script error, no 29942 (se attached screenshot)Screen Shot 2016-08-05 at 14.28.09.png

the script is:

function main() {

    var doc = app.activeDocument;

    var myLinks = doc.links.everyItem().getElements();

    var linkObj = {};

    // create inital object

    /* linkObject {

                    [path]{missingNr,

                          arrayOfMissingLinks}

                          } */

    for (var i = 0; i < myLinks.length; i++) {

        if (myLinks.status == LinkStatus.LINK_MISSING) {

            var myPath = File(myLinks.filePath).path.toString();

            if (linkObj[myPath] == undefined) {

                linkObj[myPath] = {

                    missingNr: 1,

                    missingLinks: [myLinks],

                    newPath: ''

                }

            } else {

                linkObj[myPath].missingNr++;

                linkObj[myPath].missingLinks.push(myLinks.getElements()[0]);

            }

        }

    }

    //$.writeln(linkObj.toSource());

    var myDialog = new Window('dialog', 'Link Chaser:', undefined);

    var panel1 = myDialog.add('panel', undefined, 'Double click to select new path');

    panel1.align = ['fill', 'fill'];

    var myList = panel1.add('listBox', undefined, "", {

        columnWidths: [160, 160, 130],

        numberOfColumns: 3,

        showHeaders: true,

        columnTitles: ['Old Path', 'New Path', 'Nr. of missing links']

    });

    myList.size = [450, 200];

    myList.align = ['fill', 'fill'];

    for (var missingPath in linkObj) {

        with(myList.add('item', missingPath)) {

            subItems[0].text = linkObj[missingPath].newPath;

            subItems[1].text = linkObj[missingPath].missingNr;

        }

    }

    myList.onDoubleClick = function() {

        var myNewPath = (new Folder(app.activeDocument.filePath).selectDlg("Select New Folder") || '').toString();

        myList.selection.subItems[0].text = myNewPath;

        linkObj[myList.selection.text].newPath = myNewPath;

    }

    myDialog.add('button', undefined, "Ok", {

        name: "ok"

    });

    myDialog.add('button', undefined, "Cancel", {

        name: "cancel"

    });

    if (myDialog.show() == 1) {

        for (var i in linkObj) {

            if (linkObj.newPath != '') {

                var fixedNr = 0;

                var links = linkObj.missingLinks

                for (var j = 0; j < links.length; j++) {

                    var newFile = File(linkObj.newPath + "/" + links.name);

                    if (newFile.exists) {

                        fixedNr++;

                        links.relink(newFile);

                    }

                }

                alert('In folder:\n' + linkObj.newPath + '\n' +

                    'Fixed ' + fixedNr + ' links out of ' + linkObj.missingNr + '\n' +

                    'Please check');

            }

        }

    };

}

app.doScript('main()', undefined, undefined, UndoModes.entireScript, "Link Chaser");

I have NOT changed anything, any procedure and the document is similar to the other ones so I dont understand why this is failing 😞

Any help please...???

TOPICS
Scripting

Views

367

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 ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

Moved to InDesign Scripting...

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
Advisor ,
Aug 09, 2016 Aug 09, 2016

Copy link to clipboard

Copied

Huh, it's good to see my script still circulates.

The issue is not the script, but what you are trying to import (eg one of the links you are trying to relink is corrupted)

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
New Here ,
Aug 09, 2016 Aug 09, 2016

Copy link to clipboard

Copied

Yes Vamitul – you are officially my hero :-)....

Good to hear the reason why. Any way to make the script continue the relinking and just ignore the ones it couldnt relink??

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
Advisor ,
Aug 09, 2016 Aug 09, 2016

Copy link to clipboard

Copied

LATEST

replace the line that says:

links.relink(newFile);

with

try {

   links.relink(newFile);

} catch (e) {

   alert(e);

}

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