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

Script to bulk update linked image paths

New Here ,
Sep 20, 2016 Sep 20, 2016

Hi,

We have changed our file server and now all our Illustrator files have broken links. I have found scripts for InDesign to help with this but nothing for Illustrator. Can anyone help with a script to update the path of all linked images in all Illustrator files?

The folder structure is all the same, just the server name has changed.

Thanks,

Michael

TOPICS
Scripting
3.1K
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
Adobe
Valorous Hero ,
Sep 20, 2016 Sep 20, 2016

You can do this in Illustrator without scripting, even, in this round-about way:

Go through your linked images and attach a dynamic image variable to each one ( a script can help if you have a large amount ) by selecting the image and using the lego-looking button at the bottom of the Variables panel (Window > Variables).

Once all the images are assigned a variable, use the Camera button on the Variables panel to capture the only data set you will need for this: "Data Set 1". Now that the dataset is captured, use the export XML command in the flyout menu of the Variables panel and save a 'variables.xml' file somewhere easily found. Open this file in a text editor and you will see an XML file which lists all the variables as XML tags and the file path to the previously working file as the contents of those tags. Now what you need to do is find and replace all of the occurrences of your old server name with your new one. After this text replacement operation, save the file and import it back into the Illustrator document by using the flyout menu inside of the Variables panel once again. And, well, that's it - you're done! It's still a bunch of clicks, but it's more accurate and way less clicks than having to relink each file manually. If the amount of images makes assigning a new variable to each one too much of a pain, this whole routine, or part of it can also be made into a 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
New Here ,
Sep 21, 2016 Sep 21, 2016

Thanks very much for your help, that certainly sounds like a reasonable method, however as you mention there are too many images in all different folders to try and go through and assign new variables manually, so I guess I need the script which I have no idea how to do...

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
Valorous Hero ,
Sep 21, 2016 Sep 21, 2016

This snippet ought to help you with the variable assignments. After running this, open your Variables panel and export your xml file. When you open the xml file in a text editor, do a Replace-All for instances of your old server name:

Find: "/old-server/"

Replace: "/new-server/"

Then save the xml file and import it back into your document - it should magically update.

#target illustrator

function test(){

  var doc = app.activeDocument, newVar, thisImage, newDataSet;

  for (var i = 0; i < doc.placedItems.length; i++) {

  thisImage = doc.placedItems;

  newVar = doc.variables.add();

  newVar.kind = VariableKind.IMAGE;

  newVar.name = "image_" + (i + 1);

  thisImage.contentVariable = newVar;

  }

  newDataSet = doc.dataSets.add();

  newDataSet.name = "image_collection";

};

test();

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 ,
Sep 21, 2016 Sep 21, 2016

Thanks heaps for that, excuse my ignorance but how do I actually use that 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
New Here ,
Sep 21, 2016 Sep 21, 2016

Also is this something I have to do for every Illustrator file seperately? I was wanting to cover off every file without having to go an open each one. 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
Engaged ,
Sep 24, 2016 Sep 24, 2016

Illustrator's files – is just a text files. It may be possible to apply some tool of global replace text in files? Like Total Commander or Power Grep.

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 ,
Sep 09, 2022 Sep 09, 2022
LATEST

Hey, yes, you might be onto something here!
 I renamed a .ai file to .txt and was able to open and find instances of the linked files paths.

It might be an easier write a Python program to search and replace the needed paths.

I'm not familiar with Total Commander or Power Grip. I'll look into those as they might do these things out of the box as you are suggesting.

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 ,
Sep 02, 2022 Sep 02, 2022

Has a solutin been found for this yet?
 I am in the same situation. I have thousands of files that all have linked images in them. I am switching over to a new server and every link is going to be broken.

I need to be able to automate going through each file an resaving each file after updating the path information.

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