Skip to main content
Participant
March 27, 2014
Question

Script to Rename Bracketed Photos

  • March 27, 2014
  • 1 reply
  • 480 views

I have looked around and have had no luck finding anything similar to what I would like to do. I am trying to batch rename sets of bracketed photos with something similar to the following:

Scene-Bracket

001-01

001-02

001-03

002-01

002-02

002-03

003-01

003-02

003-03

I would like the scene number to just be a sequence followed by a sequence for the 3 bracketed images

I am currently only taking brackets of 3 which should make this somewhat more simple.

I have tried to write my own script by deconstructing others but I don't really know what I am doing and have not had any luck.

If there is anything similar out there that you could point me towards it would be helpful.

Thanks.

This topic has been closed for replies.

1 reply

Participant
March 28, 2014

I think I managed to scrap together a working script.

I found a script from Muppet Mark here:

http://forums.adobe.com/message/5630065#5630065

that I reworked into the following. I have not tested it thoroughly but it initially looks like it is working. I do not know how to code so there very well could be some inherent problems in this script. All I need to do is figure out how to add the leading zeros to the final file names.

If anyone has any input and/or thoughts it would be appreciated.

Thanks.

#target bridge

#engine main

if ( BridgeTalk.appName == 'bridge' ) {

          var toolMenu = MenuElement.find( 'Tools' ),

 

          customRename = new MenuElement( 'command', 'Custom Rename', '-at the end of toolMenu', 'cflass' );

};

customRename.onSelect = function () { renameFiles(); }

function renameFiles() {

 

          if ( app.documents.length == 0 ) { return; }

 

          var i, count, doc, file, newName, scene, bracket, k, oldname, ext;

 

          doc = app.document;

 

          count  = doc.visibleThumbnailsLength;

 

                              for ( i = 0; i < count; i++ ) {

                if ( doc.visibleThumbnails.type == 'file' ) {

 

                                                  for (k = 0; k<3; k++ ) {

 

                                                  scene = Math.ceil(i/3);

 

                                                  oldName = decodeURI( doc.visibleThumbnails[i + k].name );

 

                                                  ext = oldName.replace( /^.*\./,'' );

 

                                                  bracket = k + 1;

 

                                                  newName = scene + '-' + bracket;

 

                                                  if ( ext != '' ) { newName += '.' + ext; }

 

                    file = doc.visibleThumbnails[i + k].spec;

 

                                                  file.rename( newName );

 

                                                  }

 

                                        };

 

                              };

 

          };