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?

Participant
June 13, 2017

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


Ok i try to explain it in more detail:

1.) One InDesign Document with 30 pages, on each page i placed only 1 linked pdf file. So i have a Folder with 30 single pdf files, each file only placed once on each of the 30 indesign pages. Each pdf file has a different name.

2.) Now, i got 30 new single pdf files, all new 30 files got new names, all different than the old 30 files which were linked in the indesign document. I only want indesign to automatically re-link/replace all the new 30 pdf files with the old ones, no matter that the new ones got different names. Because they got different names than the old ones, i have to manually re-link every single pdf on every single side at the indesign document and tell indesign which old file to replace with which new file.

EXAMPLE: InDesign PAGE 1 -> PDF-File linked (Name: "Job_A 1467.pdf") – re-link manually with new file (Name: "Job_B 1579.pdf"). If you do this again and again for about 300, 400, 500 pages (sometimes my documents are that big) that is a big effort and takes much time.

The size and file format of the new files will be every time still identical, only the file names are changing. The important one would be that the script automatically replaces all 30 old files with the new 30 files, in which order the new files are replaced doesn’t matter. (sure the most logical order would be to do it like (1,2,3,4 ...) or (A, B, C, D ...)

In other much shorter words: I only want to tell InDesign “you had linked these 300 files”, i delete them or move them, now you are missing them -> NOW please relink it with this new folder also with 300 files, but they got different names, but please DONT care about the different names or in which order they got placed in the indesign document, just relink all 300 old files with the 300 new files from the new folder automatically without asking me for every single page again which file you should take for replacing”.

I hope i managed it to explain my problem so everyone can understand it!