I need to batch rename and relink files in indesign

I have a whole bunch of files that I need to rename ( I need to add a prefix on to the front eg. a whole group of files called "plan.jpg" 01.jpg, 02.jpg, etc... need to now read ORD_plan.jpg, ORD_01.jpg, etc...) I can batch rename the files in adobe bridge, but I have to go in one by one and re-connect the links. Is there a script which can batch rename and relink all the files? 
Thanks!

This biterscripting script may possibly help. It takes two input arguments.
directory - directory under which the .jpg files are located
prefix - prefix which will be added to each file's name
# Script RenameJpg.txt
var str directory, prefix, list, filepath, name
cd $directory
find -n "*.jpg" > $list
while ($list <> "")
do
    lex "1" $list > $filepath ; stex -p "^/^l[" $filepath > $name
    set $name = $prefix+$name
    system copy ("\""+$filepath+"\"") ("\""+$name+"\"")
done
This is the way you would use it - copy and paste the script code into file C:/Scripts/RenameJpg.txt, then enter this command into biterscripting.
script "C:/Scripts/RenameJpg.txt" directory("C:/test") prefix("ORD_")
It will rename C:/test/plan.jpg to C:/test/ORD_plan.jpg, C:/test/01.jpg to C:/test/ORD_01.jpg, etc.
Important: I am using the 'system copy' command so that files are copied instead of renamed. Once you are happy with the test, you can change that command to 'system rename'.
Also, if the .jpg files are within subfolders of C:/test, change the 'find -n' to 'find -r -n'. -r means recursive = search in subfolders. Syntax for the find command at http://www.biterscripting.com/helppages/lf.html
Message was edited by: Peter Spier to change 'path' to 'filepath' per post below
Message was edited by: Peter Spier to change "perfix to "prefix"

Similar Messages

  • Batch renaming and relinking in InDesign CS4

    Is there a plug-in available for InDesign that will batch rename and relink placed images?
    In Quark, I used Badia Link Renamer which worked perfectly but it's not available for InDesign. (Was told they hope to have it incorporated into BigPicture for CS5.)
    Is there something similar currently available for InDesign?
    Essentially I need it to rename and relink files with random names to structured names such as:
    001_Cust_000123456789_art_r1.tif
    (I love that Bridge does batch renaming but then I have to manually update links in InDesign which is extremely time-consuming. I've also manually renamed/relinked files individually with Adobe Dialogue but it doesn't seem to be part of CS4.)
    Any help or suggestions would be greatly appreciated! Been looking for something for months.
    Thanks!

    Here is my last version of the script, it deals with multiple instances of the same file.
    Kasyan
    var myDoc = app.activeDocument;
    var myAllLinks = myDoc.allGraphics;
    var myMultipleLinks = new Array();
    var myLinksCounter = 1;
    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");
    if ( response == true )
         WriteToFile("\r--------------------- Script started -- " + GetDate() + " ---------------------\n\n");
         for ( k = 0; k < myAllLinks.length; k++ )
              var myLinkName = myAllLinks[k].itemLink.name;
         crearLabels();
         var myPages = myDoc.pages;
         // Pages
         for ( p = 0; p < myPages.length; p++ )
              var myPageNumber = pad000(myPages[p].name);
              var myLinks = myPages[p].allGraphics;
              var myASCII = 97;
              for ( k = myLinks.length - 1; k >= 0; k-- )
                   var myLink = myLinks[k].itemLink;
                   if (myLink.extractLabel("relinked") != "yes") {
                        var myOldLinkName = myLink.name;
                        var myLinkUsage = LinkUsage( myLink );
                        var myExtension = myOldLinkName.substr(myOldLinkName.lastIndexOf( "." ));
                        if (LinkUsage(myLink) == 1)
                             var myNewLinkName = myPrepend + myPageNumber + String.fromCharCode( myASCII ) + myExtension;
                             var myOldImageHDfile = new File( myLink.filePath );
                             var myRenameResult = myOldImageHDfile.rename( myNewLinkName );
                             if (myRenameResult)     {
                                  myLink.insertLabel("relinked", "yes");
                                  myLink.relink( myOldImageHDfile );
                                  try {
                                       myLink = myLink.update();
                                  catch(err) {}
                                  myASCII++;
                                  WriteToFile(((myLinksCounter < 10) ? (" " + myLinksCounter) : myLinksCounter) + " - " + myOldImageHDfile.name + " --> " + myNewLinkName + "\n");
                                  myLinksCounter++;
                             else {
                                  if (new File(myOldImageHDfile.parent + "/" + myNewLinkName + myExtension).exists) {
                                       WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + " to " + myNewLinkName + " because the file already exists\n");
                                  else {
                                       WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + "\n");
                        else {
                             if (!IsObjInArray(myLink, myMultipleLinks)) {
                                  myMultipleLinks.push(myLink);
         var myMasterSpreads = myDoc.masterSpreads;
         // Master spreads
         for ( m = 0; m < myMasterSpreads.length; m++ )
              var myMastSpr = myMasterSpreads[m];
              var myPageNumber = myMastSpr.name;
              var myPrefix = myMastSpr.namePrefix;
              var myLinks = myMastSpr.allGraphics;
              var myASCII = 97;
              for ( n = myLinks.length - 1; n >= 0; n-- )
                   var myLink = myLinks[n].itemLink;
                   if (myLink.extractLabel("relinked") != "yes") {
                        var myOldLinkName = myLink.name;
                        var myExtension = myOldLinkName.substr(myOldLinkName.lastIndexOf( "." ));
                        if (LinkUsage(myLink) == 1)
                             var myLinkLetter = (myLinks.length == 1) ? "" : String.fromCharCode( myASCII );
                             var myNewLinkName = myPrepend + '_master_' + myPrefix + myLinkLetter + myExtension;
                             var myOldImageHDfile = new File( myLink.filePath );
                             var myRenameResult = myOldImageHDfile.rename( myNewLinkName );
                             if (myRenameResult) {
                                  myLink.insertLabel("relinked", "yes");
                                  myLink.relink( myOldImageHDfile );
                                  try {
                                       myLink.update();
                                  catch(err) {}
                                  myASCII++;
                                  WriteToFile(((myLinksCounter < 10) ? (" " + myLinksCounter) : myLinksCounter) + " - " + myOldImageHDfile.name + " --> " + myNewLinkName + "\n");
                                  myLinksCounter++;
                             else     {
                                  if (new File(myOldImageHDfile.parent + "/" + myNewLinkName + myExtension).exists) {
                                       WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + " to " + myNewLinkName + " because the file already exists\n");
                                  else {
                                       WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + "\n");
                        else
                             if (!IsObjInArray(myLink, myMultipleLinks)) {
                                  myMultipleLinks.push(myLink);
         // Multiple images
         if (myMultipleLinks.length > 0) {
              for ( a = myMultipleLinks.length - 1; a >= 0; a-- )
                   processMultiUsedLinks(myMultipleLinks[a]);
         WriteToFile("\r--------------------- Script finished -- " + GetDate() + " ---------------------\r\r");
         if (myLinksCounter == 0) {
              alert("No links have been renamed", "Rename Links Script");
         if (myLinksCounter == 1) {
              alert("One link has been renamed", "Rename Links Script");
         else if (myLinksCounter > 1) {
              alert(myLinksCounter  + " links have been renamed", "Rename Links Script");
    //--------------------------------------------- Functions ------------------------------------------------
    // Check how many times the link was placed
    function LinkUsage(myLink) {
         var myLinksNumber = 0;
              for (var c =  0; c < myDoc.links.length; c++) {
              if (myLink.filePath == myDoc.links[c].filePath) {
                   myLinksNumber += 1;
         return myLinksNumber;
    // Relink the links placed more than once
    function processMultiUsedLinks(myLink) {
         var myExtension = myLink.name.substr(myLink.name.lastIndexOf( "." ));
         var myMultiUsedLink = new Array();
         var myAllLinks = myDoc.links;
         for (var d = 0; d < myAllLinks.length; d++)  {
              if (myAllLinks[d].filePath == myLink.filePath) {
                   myMultiUsedLink.push(myAllLinks[d]);
         try {
              myLink.show();
         catch(err) {}
         var myNewLinkName = prompt ("Enter a name for this image", GetFileNameOnly(myLink.name), "This image is placed " + myMultiUsedLink .length + " times");
         if (myNewLinkName) {
              if ( myNewLinkName + myExtension != myLink.name ) {
                   var myOldImageHDfile = new File( myLink.filePath );
                   var myRenameResult = myOldImageHDfile.rename( myNewLinkName + myExtension );
                   if (myRenameResult) {
                        myLink.insertLabel("relinked", "yes");
                        myLink.relink( myOldImageHDfile );
                        try {
                             myLink = myLink.update();
                        catch(err) {}
                        WriteToFile(((myLinksCounter < 10) ? (" " + myLinksCounter) : myLinksCounter) + " - " + myOldImageHDfile.name + " --> " + myNewLinkName + "\n");
                        myLinksCounter++;
                        for (f = myMultiUsedLink.length-1; f >= 0 ; f--)
                             var myCurrLink = myMultiUsedLink[f];
                             if ( myNewLinkName + myExtension != myCurrLink.name ) {
                                  myCurrLink.insertLabel("relinked", "yes");
                                  myCurrLink.relink( myOldImageHDfile );
                                  try {
                                       myCurrLink = myLink.update();
                                  catch(err) {}
                   else     {
                        if (new File(myOldImageHDfile.parent + "/" + myNewLinkName + myExtension).exists) {
                             WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + " to " + myNewLinkName + myExtension + " because the file already exists\n");
                        else {
                             WriteToFile("CAN'T RENAME LINK -- " + myOldImageHDfile.name + "\n");
         UpdateAllOutdatedLinks();
    // Clear labels in case this script has been already run on the current document
    function crearLabels() {
         for (var f =  0; f < myDoc.links.length; f++) {
              if (myDoc.links[f].extractLabel("relinked") != "") {
                   myDoc.links[f].insertLabel("relinked", "");
    function UpdateAllOutdatedLinks() {
         for(var myCounter = myDoc.links.length-1; myCounter >= 0; myCounter--){
              var myLink = myDoc.links[myCounter];
              if (myLink.status == LinkStatus.linkOutOfDate){
                   myLink.update();
    function pad000(myNumber) {
         if (myNumber >= 1 && myNumber <= 9) {
              x =  "0" + "0" + myNumber;
         } else if (myNumber >= 10 && myNumber <= 99) {
              x = "0" + myNumber;
         } else if (myNumber >= 100 && myNumber <= 999) {
              x = myNumber;
         return x;
    function GetFileNameOnly(myFileName) {
         var myString = "";
         var myResult = myFileName.lastIndexOf(".");
         if (myResult == -1) {
              myString = myFileName;
         else {
              myString = myFileName.substr(0, myResult);
         return myString;
    function IsObjInArray(myObj, myArray) {
         for (x in myArray) {
              if (myObj.filePath == myArray[x].filePath) {
                   return true;
         return false;
    function WriteToFile(myText) {
         myFile = new File("~/Desktop/Rename Links Script.txt");
         if ( myFile.exists ) {
              myFile.open("e");
              myFile.seek(0, 2);
         else {
              myFile.open("w");
         myFile.write(myText);
         myFile.close();
    function GetDate() {
         var myDate = new Date();
         if ((myDate.getYear() - 100) < 10) {
              var myYear = "0" + new String((myDate.getYear() - 100));
         } else {
              var myYear = new String ((myDate.getYear() - 100));
         var myDateString = (myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myYear + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds();
         return myDateString;

  • Package batch renaming and relinking duplicates

    A plug-in/script available for InDesign to package some folders indd files into one folder with .indd, .pdf, .idml, links and fonts in folder, if images are duplicated between documents, rename with suffix "_1, _2, ....
    I need it to rename and relink files with random names to add suffix "_1, _2, _n number"  images are in .eps, .pdf, .psd, .jpg, etc. Names such as:
    design.tif      design_1.tif  
    design.eps    design_1.eps
    abcd.psd   adcd_1.psd
    abcd.psd   adcd_2.psd  
    abcd.psd   adcd_3.psd
    abcd.psd   adcd_4.psd
    design20.tif      design20_1.tif  
    design_14.eps    design_14_1.eps
    abcd.pdf   adcd_1.pdf
    abcd.jpg   adcd_2.jpg  
    Manually update links in InDesign, which is extremely time taking. I have found many scripts, but those are either keeping only one link when a package or changing one by one in each indesign documents and than package as usual.
    Any help or suggestions would be greatly appreciated.
    Thanks!

    Thank you for your great help. It is very useful  in future.
    It is doing 90% work of the package. It keeps link folder with one link, which is coming suppose in more than two documents.
    Same name images used between documents, with may be some changes,
    I need a script to rename and relink  duplicate files with random names to add suffix "_1, _2, _n number"  images are in .eps, .pdf, .psd, .jpg, etc., and package.

  • A script to batch rename and relink images?

    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[i].itemLink.name.match(/^EQ.+/))
                    var ext = links[i].itemLink.name.substr(links[i].itemLink.name.lastIndexOf(".")),
                        old = File(links[i].itemLink.filePath),
                        eqnum = (eqcount++).toString(),
                        newname = "EQ_EF6_ESP_C1_" + a.substring(0, a.length - eqnum.length) + eqnum + ext;
                    old.rename(newname);
                    links[i].itemLink.relink(File(old.toString().replace(links[i].itemLink.name,newname)))
            else
                    var ext = links[i].itemLink.name.substr(links[i].itemLink.name.lastIndexOf(".")),
                        old = File(links[i].itemLink.filePath),
                        num = (count++).toString(),
                        newname = "EF6_ESP_C1_" + a.substring(0, a.length - num.length) + num + ext
                    old.rename(newname);
                    links[i].itemLink.relink(File(old.toString().replace(links[i].itemLink.name,newname)))
    Please note:It is not reversible.
    Regards,
    Chinna

  • Batch Rename and now files will not open

    i hope someone can help me. i moved some .dng files from an external drive to my mapbook pro using batch rename in bridge CS5. The files moved to my desktop ine, but now they will not open. When I try to open them  the digital convertor opens up. When I try to open them in photoshop it says it is a unrecognized format. They were fine ten minutes ago in bridge. does anyone have anything they can have me try? I am depserate to get these images printed up tonight and I don't have time to edit them again.

    You probably forgot to include the extension .dng or renamed with an extra dot (.) in the filename. Be surr to have only 1 dot with the three letter extension dng at the end (. dng)
    You can use Bridge for that again to rename and use the dng extension

  • Batch rename of avi files

    I am looking for the solution to batch rename multiple avi files simply.
    In iphoto, I just select a bunch of image files and using the ctrl+Shift+CMD keyboard shortcut, I input the name something like 'boat_trip_kids' I get the files renamed instantly wiith or without the suffix of a number.
    Thing is,  how to do for vdo files ?
    I read a totorial and then tried using automator to do this but I have to input the name_of_the_file in the script construction. That's ok for hundreds of files but I will have many names to use for naming of small groups of files and this won't be practical.
    Is there some way I can achieve this in automator ?
    Perhaps someone with expertise with automator can talk me through the way?
    Thx,

    Check out A Better Finder Rename. I don't know if this will do what you want but I thought I'd suggest it anyhow.
    That link is to the macupdate.com download page.  Also on that page is a Similar Software section for other apps with similar functionality.

  • Do we need to format data and log files with 64k cluster size for sql server 2012?

    Do we need to format data and log files with 64k cluster size for sql server 2012?
    Does this best practice still applies to sql server 2012 & 2014?

    Yes.  The extent size of SQL Server data files, and the max log block size have not changed with the new versions, so the guidance should remain the same.
    Microsoft SQL Server Storage Engine PM

  • I am on a trial version of  InDesign in Creative Cloud and before I purchase need to know why and the files cannot be opened by others using CS6.  Isn't Cloud compatible with CS6 design software?

    I am on a trial version of  InDesign in Creative Cloud and before I purchase need to know why and the files cannot be opened by others using CS6.  Isn't Cloud compatible with CS6 design software?

    Industry standard files such as JPEG are compatible with many brands/versions of programs
    Proprietary files such as those created by InDesign are often not backwards compatible, due to new features in newer program versions
    This is not unique to Adobe... MS Word DOCX files are not backwards compatible with earlier versions of MS Word

  • Using foreach loop container with file system task to rename and move files

    the foreach loop container will not rename and move files for me
    sukai

    duplicate of
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8f2899f1-43b0-47e0-8bd0-e082989cdcb8/file-system-task-and-foreach-loop-container?forum=sqlintegrationservices
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • I use a PC - I need to open ai and eps files - what adobe program do I need to purchase?

    I use a PC - I need to open ai and eps files - what adobe program do I need to purchase?

    You need Illustrator to open .ai files. That is, if you want to edit them.
    If you just need to place them, then tell us what you want to do with the files.

  • Can't drag and drop files into Indesign.

    My ability to dragon and drop files into InDesign has stopped. I also cannot copy and paste. I have tried dropping previously used jpg's and PDFs as well as copying text from Acrobat, Chrome and Word. I reset the prefrences with control option command shift, but still no luck - I can't drag and drop files. Also, I cannot move files with my mouse in the program.

    Nobody can help you without system information. Could be anything from graphics driver issues to a defective mouse to a busted operating system...
    Mylenium

  • Import .pdf and ai file in indesign cc

    Hi,
    I'd like to know if there's a way to import pdf and ai files in indesign cc 2014?
    Thanks

    If you're asking how to use a PDF or ai as a graphic in InDesign, File>Place is what you want. If you're asking how to manipulate the elements of a PDF or ai after it has been placed in InDesign, that's not how it works, although you can turn layers on or off in a placed ai file if you go to Object>Object Layer Options.

  • I need to create Arabic and Farsi brochures in InDesign CS6. Does anyone know where I can get a plug-in to make Middle Eastern languages work correctly from right to left?

    I need to create Arabic and Farsi brochures in InDesign CS6. Does anyone know where I can get a plug-in to make Middle Eastern languages work correctly from right to left?

    With CS6 you have to pay extra for these plugins.
    With the CC you can download different ME versions to add their functionality.

  • Adobe Bridge CC Batch Rename and File Extensions

    I use Adobe Bridge CC on my macbook pro that is running OS X 10.8.5  When I batch rename files within Bridge it automatically drops the file extension. I am able to add the extension within the naming process but would prefer if it simply defaulted to the existing extension of the files being renamed. On occasion it does do this and then the next time it is gone. What am I doing wrong?

    I don't think there is any way in which you can add to the built-in functions…
    Unless this is actually provided by one of the Adobe start-up scripts… ( I've not see it when digging about )
    You would probably need a scripted solution that can give you drop down menu of the extra options you want.

  • Batch renaming lots of files without zeroes (0065) and without 1(2), 2(2)

    Hi there,
    When renaming say 100 images, you can select three digits, and create something like:
    Image _001
    Image _002
    Image _003
    Image _004
    Image _005
    Image _067
    Image _068
    Image _069
    and so forth.
    But if you select one digit it comes out like:
    Image _1
    Image _2
    Image _3
    Image _4
    Image _5
    Image _6
    Image _7
    Image _8
    Image _9
    Image _1(1)
    Image _2(1)
    Image _3(1)
    Image _4(1)
    Image _5(1)
    Image _6(1)
    Image _7(1)
    Image _8(1)
    Image _9(1)
    Image _1(2)
    Image _2(2)
    Image _3(2)
    Image _4(2)
    Can bridge rename from say 1 to 100 without the zeros, yet still numbering consecutively without (#)?
    I'm looking for:
    Image _1
    Image _2
    Image _3
    Image _4
    Image _5
    Image _6
    Image _7
    Image _8
    Image _9
    Image _10
    Image _11
    Image _12
    Image _97
    Image _98
    Image _99
    Image _100
    Image _101
    Seems pretty simple.

    Hi,
    I have a preset that does what you are looking for..
    In Batch rename, I use a string subsitution with a regular expression "_0|_00" - which means "find _0 OR _00"
    New Filenames
    String Substitution - Original Filename - Find _0|_00 - Replace with _ 
    (make sure 'Use Regular Expression' is checked)
    See screenshots below...
    Regards..

Maybe you are looking for

  • Quicktime does not work on Win 7 64bit?

    I noticed member posting about this about 2 years ago! Is there a solution or plug on for this? Please respond ASAP!! THANKS!!

  • Materialstocks for last years

    hi guys, I have used the 2LIS_03_BX (Stock Initialization for Inventory Management   ) and 2LIS_03_BF (Goods Movements From Inventory Management). When I reviews my queries, the Goods Movements are ok. I have loaded the data into BW today as written

  • How to get a function to return a value occuring after a character

    I need to write a function to return the next value occurring after the ":" character in a column. If multiple values of ":" occurs then the function should return the sum of the next value occurring after each ":" in the column. For example a rating

  • Graphics are not imported

    Hi members, This is my first time in the forum and I hope someone can help me with my problem. I have a Word 2007 document with many pictures. The picture style is a new style of my own. Most pictures are.PNG, but some are .gifs and .jpgs When I impo

  • My iBook G4 suddenly went black and won't restart.

    This afternoon my Mac iBook G4 was running on house power (plugged into outlet) and it suddenly went blank.  It won't restart.  Any suggestions what I should check out before I spend good money on a repair shop?