Skip to main content
ascotto
Known Participant
January 27, 2015
Answered

relink images with different names

  • January 27, 2015
  • 2 replies
  • 9445 views

Hi all, I need to relink lots of -missing- images (i.e. "my_favourite_pic_001_LR.jpg") to their high resolution versions (i.e. "my_favourite_pic_001_HR.jpg"). So, is there a way to tell InDesign to 'read' all the characters but the last two before the dot, while searching for links? HR images are all in one folder, so there's no danger to relink wrong ones. I'm pretty a noob with js or applescript, but I'll be glad if someone of you could help me

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

Here is javascript (place and run from InDesign Script Panel):

var

  sourceFolder = Folder.selectDialog("Show me a source folder"),

  mLinks = app.activeDocument.links.everyItem().getElements(),

  cLink, cFile;

while ( cLink = mLinks.pop() ) {

  if (cLink.status == LinkStatus.NORMAL) continue;

  cFile = File(sourceFolder + "/" + cLink.name.replace("LR.","HR.") );

  if ( !cFile.exists ) continue;

  cLink.relink(cFile);

  }

Jarek

2 replies

Inspiring
January 11, 2021

Worked perfectly! Thanks Jump_Over. I had over 150 images I had to quickly rename (using NameChanger) adding 'GG' (GG.jpeg). I thought I'd have to find/update each image one by one in Links panel. 

Jump_Over
Jump_OverCorrect answer
Legend
January 27, 2015

Hi,

Here is javascript (place and run from InDesign Script Panel):

var

  sourceFolder = Folder.selectDialog("Show me a source folder"),

  mLinks = app.activeDocument.links.everyItem().getElements(),

  cLink, cFile;

while ( cLink = mLinks.pop() ) {

  if (cLink.status == LinkStatus.NORMAL) continue;

  cFile = File(sourceFolder + "/" + cLink.name.replace("LR.","HR.") );

  if ( !cFile.exists ) continue;

  cLink.relink(cFile);

  }

Jarek

antoine_c15137662
Participant
June 21, 2017

Hey Jarek,

I've used your first script (the one for the original query) but after selecting a folder nothing seems to happen. From the original script all I've done is replaced this:

  cFile = File(sourceFolder + "/" + cLink.name.replace("LR.","HR.") );

by that:

  cFile = File(sourceFolder + "/" + cLink.name.replace("low_res","high_res") );

my filename structure is slightly different: low_res_image_1.jpg and high_res_image_1.jpg. Should the above change search for links with the term 'low_res' and replace with the ones that have 'high_res'.

I've tried to places low and high res in the same folder then different folders, no luck! Perhaps you could point me to where I seem to go wrong?

Thanks in advance!

antoine_c15137662
Participant
June 21, 2017

I ment to move old files from original folder or to delete them --> in a doc link status will turn to "MISSED" (red circle)

Jarek


PERFECT! Thanks very much, it works brilliantly, the only thing is that I have to do it individually for each Indd files. Is there a way to apply this script to all open windows for example? That's very minor now... Regardless many thanks for your help Jarek!

antoine.