Copy link to clipboard
Copied
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.
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.
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);
}
Copy link to clipboard
Copied
Hi,
can you confirm the version of the software and operating system you are using?
Here what I would do:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Please update this thread if you find a better solution
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
How do I use this within the InDesign document?
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
(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.)
Copy link to clipboard
Copied
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){}
}
Copy link to clipboard
Copied
You just gave us a show. Thanks
Copy link to clipboard
Copied
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
See also this post by Marc Autret:
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
I just encountered this bug in another, unrelated project I'm working on. It was driving me crazy. Upvoted!
Copy link to clipboard
Copied
@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:
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 )
Copy link to clipboard
Copied
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.