Copiar link para a área de transferência
Copiado
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?
Check out my Relink images script.
Copiar link para a área de transferência
Copiado
Check out my Relink images script.
Copiar link para a área de transferência
Copiado
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.
Copiar link para a área de transferência
Copiado
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?
Copiar link para a área de transferência
Copiado
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);
}
}
}
Copiar link para a área de transferência
Copiado
Hi Anantha, thanks for chippping in! Unfortunately it didn't relink the files in the document. I appreciate the assist!
Copiar link para a área de transferência
Copiado
could you please post the IDML file and before-and-after text file? @vicentem65918498
I will check and let you know
Copiar link para a área de transferência
Copiado
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.
Copiar link para a área de transferência
Copiado
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"
Copiar link para a área de transferência
Copiado
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.
Copiar link para a área de transferência
Copiado
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!
Copiar link para a área de transferência
Copiado
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:
Copiar link para a área de transferência
Copiado
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.
Encontre mais inspiração, eventos e recursos na nova comunidade da Adobe
Explore agora