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

relink images with different names

  • January 27, 2015
  • 2 replies
  • 9450 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

ascotto
ascottoAuthor
Known Participant
January 28, 2015

It's amazing, thanks a lot! However, is there a way to add "MR" images or whatever two letters before the dot, to be all relinked to HR ones?

Jump_Over
Legend
June 13, 2017

Hey @Jump_Over!

I think this Script might help me! But i need something little different here, is it possible to change the Script in the way i need it? I will try to explain:

I've got a lot of missing images in my indesign file too (linked pdf files), and i want to relink them with new pdf files all with COMPLETE different names. So i would like that the Script automatically relink all missing pdf files with all the new ones with the different names.

It is not necessary in which sequence the pdf files will be replaced, it is only important that all missing files will be replaced with all the new ones. And one last note: The number of old missing files and the new files for relink will be always the same, so for example if i got 30 missing files i want to relink them with 30 new ones.

Thx for any help !


AndreasNRW  napisał(-a)

...So i would like that the Script automatically relink all missing pdf files with all the new ones with the different names...

What about the way by which a proper name for relinking is chosen?

Are you going, for example, to create a TXT list with 'old name - new name' lines?

How would you did it manually?

Jarek