Skip to main content
Participant
April 17, 2008
Question

Re-link lots of images? Indesign CS3

  • April 17, 2008
  • 70 replies
  • 15244 views
Hi - I posted this in the indesign forum and it was suggested to look here. I've had a quick look for a solution but thought I'd post aswell.

"Because I've resaved a load of jpegs to psds the links are now broken.

Is it possible to relink them all without doing each one manually?

The update link option is greyed out. All the psds are in the same folder. "

Thanks again
This topic has been closed for replies.

70 replies

Kasyan Servetsky
Legend
December 18, 2008
Hi all,

I remade my script again. The previous version worked extremely slowly if the document contained the same links placed several times (thanks Ed for reporting the bug). I also corrected a few minor problems.
You can get the current version of the script from here:
http://www.kasyan.ho.com.ua/relink.html

Kasyan
Participant
May 29, 2009

My friend, you are a GENIUS.  You just saved me hours and hours of time, literally.  I had 123 images that I moved to a new folder, and it took about 4 or 5 minutes for your script to re-link them.  AWESOME.

For those of you who are looking to use the script, just download it from Kasyan's site, put it in the "Program Files\Adobe\Adobe InDesign CS3\Scripts\Scripts Panel".  Then in InDesign, open the Scripts Panel (Window>Automation>Scripts), and double-click on the .js file.  Pick the NEW folder where your images are located, and VOILA.

Thanks a million, Kasyan.

Dave Cooperstein.

c.pfaffenbichler
Community Expert
Community Expert
December 3, 2008
Thanks, Kasyan!
Kasyan Servetsky
Legend
December 3, 2008
Hi all,

Ive made a new version of update path names in links script.
http://www.businessweekly.h.com.ua/relink.html
The previous one had a problem with the links placed more than once: only one instance of such a link was relinked. (Thanks to Ed for reporting about the bug.)
There was also a problem with final report. Sometimes it incorrectly stated: Nothing has been relinked.
Now the script works with links not images so you can relink text files as well (e.g. InCopy files).

If you encounter any bugs, please report me to askoldich@yahoo.com or kasyan@business.ua

Kasyan
Kasyan Servetsky
Legend
November 7, 2008
I'm so sorry, stealthrocket didn't mean any mischief.
Participant
November 7, 2008
Grrrr! I don't know how to say this without coming across sounding ungrateful for all the hard work you guys have put into this script but... in the future can we please keep the thread to the original functionality of the script? Halfway through this one the script changed from relinking images to changing the file names. I grabbed one of the code samples and ran it and now have a bunch of files with names that don't fit my naming convention when I thought I was running the relink script.
Participating Frequently
November 3, 2008
Apologies Kasyan

Thanks
Duncan
Kasyan Servetsky
Legend
November 3, 2008
Duncan,

Please use script poster when you post scripts in the forum:
This version is for ESTK2


var asciiFile = new File(File.openDialog("Open File to convert","Javascript:*.jsx;"));
OutHTM = new File(decodeURI($.getenv("TEMP")) + "/Code2HTM.txt");
asciiFile.open("r");
OutHTM.open("w");
var FileString = asciiFile.read();
asciiFile.close();
OutHTM.writeln("<PRE><BR>");
for (a=0;a<FileString.length;a++){
c=FileString;
Write(c);
}
OutHTM.writeln("</PRE>");
OutHTM.close();
OutHTM.execute();
function Write(Char){
switch (Char){
case '\n' : OutHTM.write("<BR>");
break;
case '\t' : OutHTM.write(" ");
break;
case '<' : OutHTM.write("<");
break;
case '>' : OutHTM.write(">");
break;
default : OutHTM.write(Char);
}
}
Participating Frequently
November 3, 2008
Sorry - looks like i can't even deal with the HTML of this site!

Duncan
Participating Frequently
November 3, 2008
No different to Kasyan's really - just without the function for the a,b,c ... bit


var myDoc = app.activeDocument;
var myAllLinks = myDoc.allGraphics;
var mySeen = Object;

var myPrepend = prompt("Example: thebook_08765", "Job description", "Please enter job description");
var response = confirm("Warning: You are about to rename all images linked to the foremost Indesign Document - proceed? Keep in mind - it is not reversible!");

if ( response == true )
{

for ( i = 0; i < myAllLinks.length; i++ )
{
var myLinkName = myAllLinks.itemLink.name;
if ( mySeen[myLinkName] )
{
mySeen[myLinkName]++;
} else {
mySeen[myLinkName] = 1;
}
}
var myPages = myDoc.pages;
for ( p = 0; p < myPages.length; p++ )
{
var myPageNumber = pad000( myPages

.name );
var myLinks = myPages

.allGraphics;
var myASCII = 97;
for ( i = myLinks.length - 1; i >= 0; i-- )
{
var myLink = myLinks.itemLink;
var myOldLinkName = myLink.name;
if ( mySeen[myOldLinkName] == 1 )
{
var myExtension = myOldLinkName.substr(myOldLinkName.lastIndexOf( "." ));
var myNewLinkName = myPrepend + '_P' + myPageNumber + String.fromCharCode( myASCII ) + myExtension;
var myOldImageHDfile = new File( myLink.filePath );
myOldImageHDfile.rename( myNewLinkName );
myLink.relink( myOldImageHDfile );
myLink.update();
myASCII++;
}
}
}
}

function pad000(myNumber) {
if (myNumber >= 1 && myNumber <= 9) {
x = "0" + "0" + myNumber;
} else if (myNumber >= 10 && myNumber <= 99) {
x = "0" + myNumber;
} else if (myNumber >= 100 && myNumber <= 999) {
x = myNumber;
}
return x;
}



Regards
Duncan
Participating Frequently
November 3, 2008
No different to Kasyan's really - just without the function for the a,b,c ... bit


var myDoc = app.activeDocument;

var myAllLinks = myDoc.allGraphics;

var mySeen = Object;



var myPrepend = prompt("Example: thebook_08765", "Job description", "Please enter job description");

var response = confirm("Warning: You are about to rename all images linked to the foremost Indesign Document - proceed? Keep in mind - it is not reversible!");



if ( response == true )

{



for ( i = 0; i < myAllLinks.length; i++ )

{

var myLinkName = myAllLinks.itemLink.name;

if ( mySeen[myLinkName] )

{

mySeen[myLinkName]++;

} else {

mySeen[myLinkName] = 1;

}

}

var myPages = myDoc.pages;

for ( p = 0; p < myPages.length; p++ )

{

var myPageNumber = pad000( myPages

.name );

var myLinks = myPages

.allGraphics;

var myASCII = 97;

for ( i = myLinks.length - 1; i >= 0; i-- )

{

var myLink = myLinks.itemLink;

var myOldLinkName = myLink.name;

if ( mySeen[myOldLinkName] == 1 )

{

var myExtension = myOldLinkName.substr(myOldLinkName.lastIndexOf( "." ));

var myNewLinkName = myPrepend + '_P' + myPageNumber + String.fromCharCode( myASCII ) + myExtension;

var myOldImageHDfile = new File( myLink.filePath );

myOldImageHDfile.rename( myNewLinkName );

myLink.relink( myOldImageHDfile );

myLink.update();

myASCII++;

}

}

}

}



function pad000(myNumber) {

if (myNumber >= 1 && myNumber <= 9) {

x = "0" + "0" + myNumber;

} else if (myNumber >= 10 && myNumber <= 99) {

x = "0" + myNumber;

} else if (myNumber >= 100 && myNumber <= 999) {

x = myNumber;

}

return x;

}



Regards
Duncan