Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

Relink multiple images in one go

Explorer ,
Mar 05, 2020 Mar 05, 2020

Hi,

 

Is there a way I can relink a select number of images on a document in one go rather than having to relink one by one?

 

For example, in the image below, the graphic is duplicated 112 times. Let's say I want to replace 50 of the links with a graphic that has a different price on it. At the moment, I have to select the graphics I want to change and then go through the relink procedure 50 times, which is very time-consuming (and incredibly frustrating!)

 

Is there a way to do this within InDesign? Is there a script available? I'm also happy to use Illustrator if there's a way it can be done there, although I haven't found a solution for that either.

 

Thanks for any help you guys can give.

 

Screenshot 2020-03-05 at 09.48.22.png

TOPICS
How to , Import and export , Scripting
39.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Explorer , Mar 05, 2020 Mar 05, 2020

Ah, yes sorry, I should have mentioned. Mac OS Catalina, InDesign 15.0.2.

 

That sounds like a viable workaround. I'll use that method if a quicker way doesn't show up!

 

Thanks Eric, much appreciated.

Translate
Community Expert , Mar 05, 2020 Mar 05, 2020

This assumes that you have the frames selected with the regular black arrow tool, and that there is only one linked image within that frame:

 

 

var fileToRelink = File.openDialog("Choose the file to relink to");
var selects = app.selection;

for (var i = 0; i < selects.length; i++) {
    selects[i].graphics[0].itemLink.relink(fileToRelink);
}

 

Translate
Community Expert ,
Mar 05, 2020 Mar 05, 2020

Hi,

can you confirm the version of the software and operating system you are using?

 

Here what I would do:

  • duplicate your file
  • in one version of the indd file,
    • I would delete half the images
    • in the Link panel, update the link to the new image
  • In the other version of the indd file, copy the other half of the image
  • paste the second batch into the first version
  • you should get the mix of images on the same page

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 05, 2020 Mar 05, 2020

Ah, yes sorry, I should have mentioned. Mac OS Catalina, InDesign 15.0.2.

 

That sounds like a viable workaround. I'll use that method if a quicker way doesn't show up!

 

Thanks Eric, much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 05, 2020 Mar 05, 2020

Please update this thread if you find a better solution

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 05, 2020 Mar 05, 2020

This assumes that you have the frames selected with the regular black arrow tool, and that there is only one linked image within that frame:

 

 

var fileToRelink = File.openDialog("Choose the file to relink to");
var selects = app.selection;

for (var i = 0; i < selects.length; i++) {
    selects[i].graphics[0].itemLink.relink(fileToRelink);
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 05, 2020 Mar 05, 2020

How do I use this within the InDesign document?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2020 Mar 06, 2020

https://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-po...

 

Once the script is installed, select the frames of the images you want to replace with the selection tool (black arrow), then execute the script. You will be prompted to select the image file you want to relink. The rest is magic. This is a .jsx script (ExtendScript).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2020 Mar 06, 2020

Ok, I see now. I've followed the instructions and used TextEdit to save the script, but it doesn't seem to work. I guess maybe I'm doing something wrong?

 

Screenshot 2020-03-06 at 08.32.33.pngScreenshot 2020-03-06 at 08.31.06.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2020 Mar 06, 2020

Hi Jon,

did you save the script with TextEdit app as Text only?

 

If yes, we have a serious problem with Catalina and ExtendScript scripts in the User folder of the Scripts folder:

In previous versions of OS X a *.jsx file was considered to be owned by the ExtendScript Toolkit app ( ESTK ), but now with OSX 10.15 the ESTK cannot be installed anymore, it is 32-Bit software, so my assumption is that a jsx suffix will not be recognized anymore as what it is, a script that could be run with InDesign ( or other CC apps like Illustrator, PhotoShop etc.pp. ). Usually a orderly saved ExtendScript script that lies in the User folder of the Scripts panel should run with InDesign. Maybe that changed with Catalina? That would be a serious bug with InDesign.

 

FWIW: I cannot test this because I'm not on OS X 10.15 Catalina.

Maybe someone else could test this?

 

A workaround could be to move the script file to InDesign's Script folder of the Application or to the new Community script folder in InDesign's application folder.

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2020 Mar 06, 2020

I thought I had saved it as text only but obviously not! I just tried saving the script again and it worked! I must have done something different as the original file that didn't work has 'TXT' in the icon and the new one doesn't.

 

Thanks, everyone for you help. It works a treat and will save me a lot of time in the future!

 

Screenshot 2020-03-06 at 12.35.54.pngScreenshot 2020-03-06 at 12.36.08.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 06, 2020 Mar 06, 2020

Sometimes by default, TextEdit can be set to do the text in RTF format, which would mess up the .jsx coding. To ensure you have it correct in the future, in TextEdit you'd select the text and go to Format > Make Plain Text just to be sure. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 06, 2020 Mar 06, 2020

I did actually have the format set to Plain Text. I worked out that in the Save dialog box, I should have 'un-ticked' the option to use .txt if no extension is provided, even though I did put .jsx at the end of the filename when saving.

 

Screenshot 2020-03-06 at 16.33.06.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 01, 2021 Apr 01, 2021

Hi Brian.

 

Is there a trivial fix to make this work for links selected in the Links panel? I have a document with hundreds of duplicated images that need to stay slightly renamed, but they're page design clutter, so they're all over the place rather than in one frame.

 

If it's non-trivial, please don't worry. I was given idml to work from, so I can always look at editing the raw xml -- and thanks either way.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 01, 2021 Apr 01, 2021

(I should probably specify (1) that the original links are all to sub-pages of an illustrator archive, which has now been split into separate updated .psds, so none of the batch solutions I've found so far work; and (2) I'm on CS6 PC.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Scripting can't read what links are selected in the panel. You can iterate through all links in a doc and try to relink. Not sure how the fact these are subpages of ai files affects things. Check the link name before plugging in replacing the text in the nameOfLinkToReplace variable. I think maybe it should have a a number at the end indicating which page of the ai file it is?

 

var fileToRelink = File.openDialog("Choose the file to relink to");
var selects = app.activeDocument.allGraphics;
var nameOfLinkToReplace = "my-link-name.ai";
var aLink;

for (var i = 0; i < selects.length; i++) {
     try {
        aLink = selects[i].itemLink;
        if (aLink.name == nameOfLinkToReplace) {
            aLink.relink(fileToRelink);
        }
     } catch(e){}
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 03, 2020 Dec 03, 2020

You just gave us a show. Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2021 Apr 01, 2021

Hi Brian,

don't know if it will be relevant, but also see into the following issue if you like to change the visibility of graphic layers of placed AI, PSD, PDF files and InDesign pages:

 

Scripting | graphicLayerOptions : Changing visibility of graphicLayer will change ID number of placed graphic
Uwe Laubender, Jul 24, 2019

https://indesign.uservoice.com/forums/913162-adobe-indesign-sdk-scripting-bugs-and-features/suggesti...

 

See also this post by Marc Autret:

https://community.adobe.com/t5/indesign/activating-object-layers-basing-on-document-layers/m-p/46539...

 

Regards,
Uwe Laubender

( ACP )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2021 Apr 01, 2021

I just encountered this bug in another, unrelated project I'm working on. It was driving me crazy. Upvoted! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 20, 2024 Jun 20, 2024

@brian_p_dts said: "… I just encountered this bug in another, unrelated project I'm working on. It was driving me crazy. Upvoted! "

 

Hi Brian,

as you can read from Marc Autret's post from 2012 there is a way to circumvent this problem:

https://community.adobe.com/t5/indesign-discussions/activating-object-layers-basing-on-document-laye...

 

Also see this article by Marc Autret on indiscripts.com from the year 2013:

 

2/ Graphics, Geometry and Coordinate Spaces
Syncing InDesign and Illustrator Layers

https://indiscripts.com/post/2013/05/indesign-scripting-forum-roundup-4#hd2sb1

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2024 Jun 19, 2024

First, you must have all the links you want to relink in a single folder with the same name. Then, highlight all of the links in the links panel. Select the hamburger menu and choose "Relink to Folder..." to open the folder. You will receive a notice if any links are unsuccessfully relinked. You can sort by the path name in the column to see which files need to be relinked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 07, 2025 Aug 07, 2025
LATEST

Even better when you get AI to help you choose the input option when linking to a multiple page document.  Script below.

johnnym76669178_0-1754603151044.png

// Check if there is an active document and a selection
if (app.documents.length > 0 && app.selection.length > 0) {

// Prompt the user to select a file to place
var myFile = File.openDialog("Choose a file to place");

// Proceed only if the user selected a file
if (myFile) {
var mySelection = app.selection;

// --- Step 1: Process the FIRST frame to set the options ---
// By calling place() with 'true', you show the dialog for the first item.
// InDesign will remember the settings you choose for this session.
try {
mySelection[0].place(myFile, true);
} catch(e) {
alert("Could not place the file in the first selected frame. Aborting script.");
// We exit here because without the first placement, we have no settings to apply to the others.
exit();
}

// --- Step 2: Process the REST of the frames ---
// Now, loop through the remaining items, starting from the second one (index 1).
for (var i = 1; i < mySelection.length; i++) {
try {
// Call place() with 'false' (or no second argument) to use the
// previously set import options without showing the dialog again.
mySelection[i].place(myFile, false);
} catch(e) {
// Skip any item that can't contain a file.
}
}
}

} else {
alert("Please select one or more frames before running this script.");
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines