Skip to main content
andrewn63997035
Participating Frequently
January 24, 2019
Answered

Script to batch rename, have first file as a number, the rest sequential alphabetical

  • January 24, 2019
  • 5 replies
  • 2820 views

I just can't seem to figure this one out! The database I'm working with has a rule that the first image needs to be numerical and the rest of the image span to be sequential alphabetical.

For example, I'll have these images:

IMG_2013.jpg

IMG_2014.jpg

IMG_2015.jpg

IMG_2016.jpg

IMG_2017.jpg

and need to rename them for whatever the UPC is, for example:

982371818.jpg

982371818a.jpg

982371818b.jpg

982371818c.jpg

982371818d.jpg

This topic has been closed for replies.
Correct answer Lumigraphics

You really need a script for this. Is there a list of what files use what filenames? I have a rename script that I use in production, this is a modified version that will accept an input and rename selected files based on that. You could enumerate as many variants as you needed.

#target bridge

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

    FT = MenuElement.create('command', 'Rename', 'at the end of Tools');

    FC = MenuElement.create('command', 'Rename', 'after Thumbnail/Open', this.menuID);

    }

FT.onSelect = function(){

    Renamer1();

    }

FC.onSelect = function(){

    Renamer1();

    }

function Renamer1(){

    app.synchronousMode = true;

    var thumbs = app.document.selections;

    var newName = '';

    var newNameU = '';

    var Title = [];

    var counter = 0;

    var variant = ['a', 'b', 'c', 'd'];

    try{

        newName = prompt('Enter part number');

        if(newName != null){

            newNameU = newName.toUpperCase();

            for (var a in thumbs){

                var selectedFile = thumbs.spec;

                Title = selectedFile.name;

                Title = (Title.split( '.' ))[0];

                thumbs.name = thumbs.name.toUpperCase();

                thumbs.name = newNameU + variant[(counter)] + '.jpg';

                counter++;

                thumbs.name = thumbs.name.toUpperCase();

                }

            }

        }

    catch(e){

        }

    app.document.refresh();

    app.synchronousMode = false;

    }

Chuck Uebele
Community Expert
Community Expert
January 24, 2019

Moving this thread to the Bridge Scripting forum.

LumigraphicsCorrect answer
Legend
January 24, 2019

You really need a script for this. Is there a list of what files use what filenames? I have a rename script that I use in production, this is a modified version that will accept an input and rename selected files based on that. You could enumerate as many variants as you needed.

#target bridge

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

    FT = MenuElement.create('command', 'Rename', 'at the end of Tools');

    FC = MenuElement.create('command', 'Rename', 'after Thumbnail/Open', this.menuID);

    }

FT.onSelect = function(){

    Renamer1();

    }

FC.onSelect = function(){

    Renamer1();

    }

function Renamer1(){

    app.synchronousMode = true;

    var thumbs = app.document.selections;

    var newName = '';

    var newNameU = '';

    var Title = [];

    var counter = 0;

    var variant = ['a', 'b', 'c', 'd'];

    try{

        newName = prompt('Enter part number');

        if(newName != null){

            newNameU = newName.toUpperCase();

            for (var a in thumbs){

                var selectedFile = thumbs.spec;

                Title = selectedFile.name;

                Title = (Title.split( '.' ))[0];

                thumbs.name = thumbs.name.toUpperCase();

                thumbs.name = newNameU + variant[(counter)] + '.jpg';

                counter++;

                thumbs.name = thumbs.name.toUpperCase();

                }

            }

        }

    catch(e){

        }

    app.document.refresh();

    app.synchronousMode = false;

    }

Participating Frequently
May 8, 2024

Is there an update for this specific script for Adobe Bridge 2024? I get the following error message when I try to load it 

Legend
May 9, 2024

The error message isn't there anymore, but when I go to Rename, nothing happens. 


I recommend using Bridge 14 (2024), not 13 (2023), although both are problematic. The script I posted is from 2019 and I have not tested it with Brdge 13 or 14. Adobe broke a lot of things and yes a new script may not work. You can use Batch Rename or make changes to this script as needed.

Chuck Uebele
Community Expert
Community Expert
January 24, 2019

Also, how many images do you have within a set of UPC codes? 27 or less?

Stephen Marsh
Community Expert
Community Expert
January 24, 2019

Further to Chuck’s second suggestio, I’d just select one file then batch rename without the sequential alpha character/s.

Then invert the selection and batch rename again, adding the sequential alpha.

Should be pretty fast to do with keyboard shortcuts and presets.

andrewn63997035
Participating Frequently
January 24, 2019

I have over 2400 images and there are over 800 image sets. How can I invert the selection? I understand the batch rename for the singular image but don't know what you mean by inverting the selection to name the rest. Thanks for any additional input!

Chuck Uebele
Community Expert
Community Expert
January 24, 2019

How do you get the UPC number? Is it a folder name?

Chuck Uebele
Community Expert
Community Expert
January 24, 2019

Without a script, the only way to do that is to manually rename the first file, then use the batch rename to do the rest.

andrewn63997035
Participating Frequently
January 24, 2019

I'm looking for a script solution if possible. I have over 800 UPC tied image sets to work on.  That way would double the workload, but appreciate the suggestion.