Skip navigation
Currently Being Moderated

relink images to another folder (change path)

Apr 12, 2012 2:35 AM

Hi,

 

I have 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:

 

 

#target indesign

// Relink file path.js

 

 

 

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();

}

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points