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

Automating relinking renamed images in InDesign

Community Beginner ,
Aug 06, 2025 Aug 06, 2025

I currently have a script that renames files and outputs a before-and-after text file, (e.g. origFilename.tif ==> newFilename.tif) to act as a guide to help manually relink said files in a document. Is there a way to automate that process with a script that uses that text file?

TOPICS
How to , Scripting
435
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 1 Correct answer

Valorous Hero , Aug 06, 2025 Aug 06, 2025

Check out my Relink images script.

Translate
Valorous Hero ,
Aug 06, 2025 Aug 06, 2025

Check out my Relink images 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
Community Beginner ,
Aug 06, 2025 Aug 06, 2025

Thanks for the help! I'm testing the scripts now, but it doesn't seem to be relinking the images to the new filenames. Will continue to peck away at it for a little bit longer and get back to you. I want to make sure I'm following the steps correctly.

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 ,
Aug 06, 2025 Aug 06, 2025

So far, your relink script hasn't been working by using the arguments text file (each line item in my text file is comma separated). I have been using your batch processor script in conjunction with the relink images script, and while it's not throwing errors, it's also not relinking the renamed images. Both the new renamed images and the argument text files are in the same folder as the InDesign file. Am I missing a step?

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 ,
Aug 06, 2025 Aug 06, 2025

Could you plz try below script? @vicentem65918498 
https://community.adobe.com/t5/indesign-discussions/renaming-links-for-already-placed-image-files/m-...

Script from @m1b 

// Open the CSV file
var file = File.openDialog("Open CSV File", "*.csv");
if (!file) {
    exit();
}
file.open("r");
// Read the CSV file into an array
var csvArray = [];
while (!file.eof) {
    csvArray.push(file.readln().split(","));
}
file.close();
// Get all linked images in the document
var myLinks = app.activeDocument.links;
// Loop through each row in the CSV file
for (var i = 0; i < csvArray.length; i++) {
    // Get the current name and new name from the CSV file
    var currentName = csvArray[i][0];
    var newName = csvArray[i][1];

    // Loop through each linked image in the document
    for (var j = 0; j < myLinks.length; j++) {
        var myLink = myLinks[j];
        // If the current name matches the linked image name, rename it
        if (myLink.name == currentName) {
            // make a new File object
            var newLinkedFile = File(myLink.filePath.replace(myLink.name, newName));
            // if file exists at the new file path, relink
            if (newLinkedFile.exists)
                myLink.relink(newLinkedFile);
        }
    }
}

 

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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 ,
Aug 06, 2025 Aug 06, 2025

Hi Anantha, thanks for chippping in! Unfortunately it didn't relink the files in the document. I appreciate the assist!

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 ,
Aug 06, 2025 Aug 06, 2025

could you please post the IDML file and before-and-after text file? @vicentem65918498 

I will check and let you know

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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 ,
Aug 07, 2025 Aug 07, 2025

Did you try to test it using the example files I posted next to the script?
I wrote this script for my client, and it worked as expected.

Additionally, I have retested both scripts in InDesign 2024 for Windows, and they work on my end, both with & without the argument files.

Note: characters may look identical but have different Unicode values — e.g., English a (0061)  and Cyrillic a (0430). That's a common source of issues for those who use non-English characters.

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 ,
Aug 12, 2025 Aug 12, 2025

Yes, the test files worked flawlessly. I've tried variations on the pop-up window (trying csv vs txt files, the separator settings) for my files and the report file output shows the document name and it's location on the computer, and that's about it. 
"Date & time: 8/12/25 8:16:4 Running script: Relink images.jsx --------------------------------------------------------- Document name: Doc1Test.indd

Document path: /Users/dam/Desktop/RESOURCES/00 AppleScript Sandbox/RelinkTest/HIRES"

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 ,
Aug 12, 2025 Aug 12, 2025

After further tinkering, I think I found the obstacle. Part of my process renames the files and moves everything together into a new folder (mechanical and linked images). But because the original links still have their original paths in the InDesign file, it doesn't "see" the new filenames because they have all been moved into a new folder. This means that for either @Anantha Prabu G  or @Kasyan Servetsky  scripts to work, I have to relink the files after moving and before renaming. It's a work-around, but I was hoping that either script would not require that additional step, unless there's a way to point it to the same folder as the INDD. Either way, your scripts do work as intended. I just have to consider my options as to whether or not to add the workaround as par tof the process.

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 ,
Aug 18, 2025 Aug 18, 2025

Final update: While the work-around steps I've taken to make use of the scripts have helped, I have noticed one other minor glitch; when it auto-relinks, I notice that sometimes, images are re-scaled to fit the frame.  It doesn't happen all the time, and there's no idicator or error thrown. This is for @Kasyan Servetsky script. Wanted to give you a heads-up. Thanks for all the help!

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 ,
Aug 19, 2025 Aug 19, 2025
quote

Final update: While the work-around steps I've taken to make use of the scripts have helped, I have noticed one other minor glitch; when it auto-relinks, I notice that sometimes, images are re-scaled to fit the frame.  It doesn't happen all the time, and there's no idicator or error thrown.


By @vicentem65918498

 

Is it possible you have this checked in Preferences > General:

 

leor_0-1755632795302.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 Beginner ,
Aug 19, 2025 Aug 19, 2025
LATEST

Hi @leo.r , thanks for the response. It is unchecked by default. Part of what we/I do is intaking of files from outside vendors, renaming/relinking and prep for archive, so we make sure that's unchecked so we don't change the composition/layout of InDD files.

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