3 Replies Latest reply on Aug 10, 2015 7:49 AM by Vamitul

    Editing a current filename to add a suffix in InDesign


      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[i].itemLink.name.substr(links[i].itemLink.name.lastIndexOf(".")),

                          old = File(links[i].itemLink.filePath),

                          num = (count++).toString(),

                          newname = myPrepend + a.substring(0, a.length - num.length) + num + '_' + myLanguage + ext