4 Replies Latest reply: Jan 5, 2012 8:11 AM by RWSP RSS

    Batch Rename - Two File Formats with Same Name

    MartinKain Community Member

      Hi everyone!

       

      I'm having troubles using the batch rename function i Bridge CS5.

       

      I've got several pictures that I've captured in both jpeg and raw. When importing the pics with windows photo import they get the same name. This means that I've got one JPG and one RAW file which contains the "same" picture, and have same name as shown below:

       

      Untitled.png

       

      What I would like to do is to rename the pictures, but still have Bridge name the same pictures with the same name as shown below:

       

           IMG_1268.CR2          ->          Picture 2011 - 0001

           IMG_1268.JPG          ->          Picture 2011 - 0001

           IMG_1269.CR2          ->          Picture 2011 - 0002

           IMG_1269.JPG          ->          Picture 2011 - 0002

       

      Is this even possible? And if possible, how?

       

      Thanks in advance

      Martin

        • 1. Re: Batch Rename - Two File Formats with Same Name
          Paul Riggott Community Member

          Most things are possible and so is this..

          Make sure you do a test first by copying the files to a temp folder!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

           

          First copy the script below and paste it into ExtendScript Toolkit (this gets installed with Photoshop)

           

           

          #target bridge
          var sels = app.document.selections;
          for(var a in sels){
          var f = decodeURI(sels[a].spec.name);
          var newName = "Picture 2011 - "+ zeroPad((f.match(/\d{4}/)[0]-1267).toString(),4)+ f.match(/\....$/);
          sels[a].spec.rename(newName);
          }
          function zeroPad(n, s) { 
             n = n.toString(); 
             while (n.length < s)  n = '0' + n; 
             return n; 
          }
          
          

           

          Now open Bridge and select the files you want to rename, then run the above script from ExtendScript Toolkit.

          • 2. Re: Batch Rename - Two File Formats with Same Name
            RWSP Community Member

            What is the problem that you are experiencing?  I have successfully batch-renamed in Bridge files with the same file name and different types (extensions).  I just tried a test - two image files with same file name in a test folder: one a .cr2, the other a .jpg.  The .cr2 had a sidecar .xmp file (same file name) so there are three files in the directory.  I selected the two files in Bridge, performed a batch rename from _mg.3333 to 1234.3333.  Bridge correctly displayed rename in its Preview (bottom of batch rename panel), and all three files were successfully renamed.

            • 3. Re: Batch Rename - Two File Formats with Same Name
              Paul Riggott Community Member

              You can't do this with the batch rename as maths and zero padding is required to produce the target filename.

              The convention required ..

              IMG_1268.CR2 -> Picture 2011 - 0001.CR2 

              IMG_1268.JPG -> Picture 2011 - 0001.JPG

              IMG_1269.CR2 -> Picture 2011 - 0002.CR2

              IMG_1269.JPG -> Picture 2011 - 0002.JPG

              So the renaming needs to subtract 1267 from the number in the orignal document, hence the script above.

              • 4. Re: Batch Rename - Two File Formats with Same Name
                RWSP Community Member

                That would explain a difference.  In my renaming I'm using only string substitution, not appending sequence numbers.