Copy link to clipboard
Copied
Hello, everyone!
First of all, I did search for this before asking and found many similar scripts for this, but as I don't know how to make or edit scripts, I couldn't use them...
I work at a company that makes school books. Each InDesign file we make can have hundreds of images, of varied extensions (.ai, .eps, .tif, .psd).
We now need to rename those images to a default naming system we defined. This is taking hours, even days to do manually.
Those images currently have varied names, so we'd need to ignore what's there, we just need a configurable prefix (like "EF6_ESP_C1_"), then a 4-digit number starting at 0001 and numbering the rest (if there's say a .tif and then a .ai, it'd have to be 0001.tif and 0002.ai), then the extension it already had.
Preferably, but not required, if it could read that the image already had an "EQ" in the file name, it could rename them to another prefix and count those separately from 0001, as we work Equation images separately, but if this can't be done or is too difficult to do, then just have them named and numbered with the others.
Could anyone be so kind as to help me with this? Thank you very much!
Try this,
...var doc = app.activeDocument,
links = doc.allGraphics, count = 1, eqcount = 1, a = "0000";
for(var i=links.length-1;i>=0;i--)
{
if(links.itemLink.name.match(/^EQ.+/))
{
var ext = links.itemLink.name.substr(links.itemLink.name.lastIndexOf(".")),
old = File(links.itemLink.filePath),
eqnum = (eqcount++).toString(),
newname = "EQ_EF6_ESP_C1_" + a.substring(0, a.length - eqnum.length) + eqnum + e
Copy link to clipboard
Copied
Hi, I don't know a way to rename all the images in InDesign, but if you have a machintosh computer I can easly tell you how to do it
Copy link to clipboard
Copied
We use Macs in the company, yes. I'd appreciate it. Would that way rename all images AND update the links in InDesign? If it were just renaming it, we could do it in Bridge...
Copy link to clipboard
Copied
Hi Maira
This is Possible in InDesign Windows also.
(1) Collect All images
(2) Segregate the Extension and Stored one variable
(3) Store Variable to Add your numbering ....etc...
(4) now once again add the separated extension value
(5) Finally rename using Re-Link options.
Thanks & Regards
T.R.Harihara Sudhan
Copy link to clipboard
Copied
Well, I had the same problem some days ago. Automator is a default application in machintosh, it allows you to choose a folder and rename al the files in it. You can automate the renaming in sequence (EQ01, EQ02, EQ03). If the link folder of InDesign has different names, all the files will be renamed in sequence.
Instructions:
1 - open Automator
2 - chose workflow
3 - type "get specified finder items" and double click it to add this action in the workflow
4 - type "rename finder items" and double click it to add this action in the workflow
5 - add the folder you have to rename in the first action
6 - in the second action choose "make sequential"
7 - set the other name setting in order to get the name you want
8 - save and choose as "application" in the saving options
Now you have an action that rename all the files in that folder anytime you click it
In alternative, you can choose to not save and play the action in automator
Copy link to clipboard
Copied
Harihara: the logic of that makes perfect sense to me, thanks! However, as neither I nor anybody else in the company know how to make scripts, I wouldn't be able to put that to practice.
Lorenzo: That would rename all the images, yes... but wouldn't that require us to relink the images one by one in InDesign after the batch renaming?
Copy link to clipboard
Copied
No, when you rename all the files, InDesign still keep the original links and asks you to update them.
Once you renamed all the files, just go on the link panel in InDesign: you will see that all the links have a yellow triangle which means you have to update them
> than, you click botton in the top-right corner of the links menu and click "update all links"
Copy link to clipboard
Copied
Try this,
var doc = app.activeDocument,
links = doc.allGraphics, count = 1, eqcount = 1, a = "0000";
for(var i=links.length-1;i>=0;i--)
{
if(links.itemLink.name.match(/^EQ.+/))
{
var ext = links.itemLink.name.substr(links.itemLink.name.lastIndexOf(".")),
old = File(links.itemLink.filePath),
eqnum = (eqcount++).toString(),
newname = "EQ_EF6_ESP_C1_" + a.substring(0, a.length - eqnum.length) + eqnum + ext;
old.rename(newname);
links.itemLink.relink(File(old.toString().replace(links.itemLink.name,newname)))
}
else
{
var ext = links.itemLink.name.substr(links.itemLink.name.lastIndexOf(".")),
old = File(links.itemLink.filePath),
num = (count++).toString(),
newname = "EF6_ESP_C1_" + a.substring(0, a.length - num.length) + num + ext
old.rename(newname);
links.itemLink.relink(File(old.toString().replace(links.itemLink.name,newname)))
}
}
Please note:It is not reversible.
Regards,
Chinna
Copy link to clipboard
Copied
Chinnadk:
That worked out perfectly! Thank you so much!
Any chance you could make it prompt the user for a prefix instead of having it fixed? It was easy enough for us to figure out how to change the script for that specific thing, but we have a big rotation of designers in the company and it could be troublesome to explain to each new one how to change the script.
Again, thank you very much
Copy link to clipboard
Copied
Nevermind, we were able to frankenstein it from other scripts we found in these forums (I hope that's ok!) and it worked beautifully.
If anyone else needs it:
var myDoc = app.activeDocument;
var myPrepend = prompt("Example: thebook_08765", "Job description", "Please enter job description");
if (!myPrepend) exit();
var response = confirm("Warning: You are about to rename all images linked to the foremost Indesign Document - proceed? Keep in mind - it is not reversible!", false, "Rename Links Script");
var doc = app.activeDocument,
links = doc.allGraphics, count = 1, eqcount = 1, a = "0000";
for(var i=links.length-1;i>=0;i--)
{
var ext = links.itemLink.name.substr(links.itemLink.name.lastIndexOf(".")),
old = File(links.itemLink.filePath),
num = (count++).toString(),
newname = myPrepend + a.substring(0, a.length - num.length) + num + ext
old.rename(newname);
links.itemLink.relink(File(old.toString().replace(links.itemLink.name,newname)))
}
Copy link to clipboard
Copied
Can this be modified to apply only to .tif and .psd files? How?
Thanks.
Copy link to clipboard
Copied
Using @Maira.Damasio's script, I found that if a link is used more than once in a document, it will only relink the first occurrence of it, leaving the others as missing links.
Is there a fix for this?
If nothing else, is there a way to create a .txt log of the old and new file names for reference to manually relink?
Copy link to clipboard
Copied
In this script you can see how to handle multi-placed links -- check out the Relink function.
— Kas
Copy link to clipboard
Copied
The website link for the script doesn't work could you post the script here, please. Thank you 🙂
Copy link to clipboard
Copied
See also this post -- a similar script which handles multi-placed links.