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)
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
if (newFile.exists) {
fixedNr++;
links
}
}
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...???
Copy link to clipboard
Copied
Moved to InDesign Scripting...
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)
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??
Copy link to clipboard
Copied
replace the line that says:
links
with
try {
links
.relink(newFile); } catch (e) {
alert(e);
}