relink images to another folder (change path)

Hi,

I found a script to relink images to another folder (images have the same name, only the path is different)
Now I want to use the script in a book with severall documents. Does anyne know how I can open every document in my book run the script, save the document?

this is the script:

if (app.documents.length == 0) {
err(“No open document. Please open a document and try again.”, true);
}

var myDoc = app.activeDocument;
var myLinks = myDoc.links;
var myCounter = 0;

if (myLinks.length == 0) {
err(“This document doesn’t contain any links.”, true);
}

for (i = myLinks.length-1; i >= 0 ; i–) {
var myLink = myLinks[i];
var myOldPath = myLink.filePath;
if (File.fs == “Windows”) {
var myNewPath = myOldPath.replace(“Content\Pricelist\Catalog\BE”, “Content\Pricelist\Catalog\NL”);
}
else if (File.fs == “Macintosh”) {
var myNewPath = myOldPath.replace(“Content:Pricelist:Catalog:BE”, “Content:Pricelist:Catalog:NL”);
}
var myNewFile = new File(myNewPath);
if (myNewFile.exists) {
myLink.relink(myNewFile);
myCounter++;
}
}

if (myCounter == 1) {
alert(“One file has been relinked.”, “Finished”);
}
else if (myCounter > 1) {
alert(myCounter + " files have been relinked.", “Finished”);
}
else {
alert(“Nothing has been relinked.”, “Finished”);
}

function err(e, icon){
alert(e, “Update path names script”, icon);
exit();
}

hi,

var docPathsArrayOfactiveBook = app.activeBook.bookContents.everyItem().fullName;

should give you all document paths of the active book …