Copy link to clipboard
Copied
Hi there!
I have been searching through the forums trying to find something that would help me edit file names so that they include a suffix at the end. I did find some scripts that have gotten me to a point where I can rename the file with the shortname (var myPrepend), have it add a number, and then have it add the language suffix. However, I would like to keep the name of the original file and just add the language suffix if possible. The code below does help if I want to rename files completely but I would also like an option that will literally just add "_es" or "_fr" and others.
In addition to that, I would like to specifically target EPS and or ILLUSTRATOR files ONLY. I do not want to change the names of tiffs, jpegs, or anything else.
Is this at all possible? Thank you in advance!
Here is what I have so far:
var myDoc = app.activeDocument;
var myPrepend = prompt("Please enter issue shortname.\nExample: Client_Project", "Issue Shortname");
if (!myPrepend) exit();
var myLanguage = prompt ("Please enter language suffix.\nExample: _es (Spanish)", "Enter language suffix");
if (!myLanguage) exit();
var response = confirm("Warning: You are about to rename all images linked to the foremost Indesign Document - proceed?\n Keep in mind - it is not reversible!", false, "Rename Links Script");
if (!response) exit();
var doc = app.activeDocument,
links = doc.allGraphics, count = 1, eqcount = 1, a = "000" ;
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 + '_' + myLanguage + ext
old.rename(newname);
links.itemLink.relink(File(old.toString().replace(links.itemLink.name,newname)))
}
Copy link to clipboard
Copied
var fname=links.itemLink.filePath;
ext = fname.substr(fname.lastIndexOf(".")),
base=fname.substring(0,fname.lastIndexOf(".")),
old = File(links.itemLink.filePath),
num = (count++).toString(),
newname = myPrepend + base+a.substring(0, a.length - num.length) + num + '_' + myLanguage + ext;
Copy link to clipboard
Copied
Thanks for responding so quickly Vamitul! I am just not clear on what exactly I should be replacing, taking out, and what I should be leaving.
And would you happen to know how I would be able to apply it only to eps files?
Copy link to clipboard
Copied
In your last "for" block, replace your var block with mine.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now