Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jan 23, 2019 Jan 23, 2019

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

TOPICS
Scripting
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 24, 2019 Jan 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.onSele

...
Translate
Community Expert ,
Jan 23, 2019 Jan 23, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 23, 2019 Jan 23, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2019 Jan 23, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 23, 2019 Jan 23, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2019 Jan 24, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2019 Jan 24, 2019

Well you did not mention that to begin with! The better the info provided the better the reply.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2019 Jan 24, 2019
I understand the batch rename for the singular image but don't know what you mean by inverting the selection to name the rest.

Perhaps pictures will clarify...

1. Rename single file:

1.png

2. Invert the single selected file in order to select all other files in the folder:

2.png

3. Rename the remaining files with sequential letter, if there are more than 26 the batch rename will cycle through from the beginning using double letters, such as aa, bb, cc etc:

3.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2019 Jan 24, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 24, 2019 Jan 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;

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 24, 2019 Jan 24, 2019

I will give this a try!

So how it works is the client gives me a spreadsheet that has three columns. One is the UPC, Title Description (not important on my end) and the image span. For Example:

UPC                    Description                    Image Number

982371818      Fleece Blanket         2013-2017

All 2400 images are in the same folder. To answer a few other individuals questions the image sequences are under 27 images. They are usually 8-15 images per UPC.

So for this section of the script, I would just keep adding letters to it, perhaps the max images I believe would correlate up to Z if needed yet?

    var variant = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z];

I appreciate everyone's input on this so far. I've been a designer for over a decade and have recently been getting into larger scale production levels.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 24, 2019 Jan 24, 2019

Update, I modified your script, and it's working, THANK YOU!!!!

Here's what I ended up doing. Since I needed the first one to just be the digits I marked the first variant as nothing followed alphabetically, example:

'', 'a', 'b', 'c',

all the way to Z.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 24, 2019 Jan 24, 2019

Two more questions

1. How can I assign a hotkey to the script now? I know how to create them in PS but not seeing this option in Bridge? I am using Windows 10.

2. For the script, would there be something I can add to the existing script that will select the copy the first image to another folder within the same directory?

For Example:

Main Directory:

9831983.jpg

9831983a.jpg

9831983b.jpg

9831983c.jpg

9831983d.jpg

Main Directory>Thumbails:

9831983.jpg

I've made an adjustment to the code and the first step is working well with my modifications, just realized about the above part in mention:

#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', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];

    try{

        newName = prompt('REF NUMBER');

        if(newName != null){

            newNameU = newName.toLowerCase();

            for (var a in thumbs){

                var selectedFile = thumbs.spec;

                Title = selectedFile.name;

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

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

                counter++;

                }

            }

        }

    catch(e){

        }

    app.document.refresh();

    app.synchronousMode = false;

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 25, 2019 Jan 25, 2019

You can move files with a script as well, and you could even read and parse the CSV file. If I was doing thousands of these I would likely do that instead of manually typing it in.

if(!Folder('foldername').exists){

Folder('foldername').create();

}

thumbs.copyTo('foldername');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 28, 2019 Jan 28, 2019

Thanks! Hey I tried that script and it's saying that thumbs is not undefined. I tried messing around with it and can't seem to define it. I want to move the first file that does not have any alphabetical characters. Is that the full script I should use that you provided?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 28, 2019 Jan 28, 2019

That's just the syntax you would use. You'll need to add it to the existing script or write the rest of it to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 28, 2019 Jan 28, 2019

Sorry for being too needy but I tried to do it several different ways and it kept throwing me errors. Where would I add this to the existing script? I don't know this too well 😕 So with that script let's say the root folder is JPEG I'm working in and I need the first image of each set to be moved to THUMBNAIL within the existing script? This is all new to me

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 29, 2019 Jan 29, 2019

Extendscript is an offshoot of Javascript so it works the same way.

You need to declare any variables and then figure out what value they have. You can get the parent folder of your current image and create that new folder as needed.

You may want to download the Bridge SDK, it is really helpful in working with scripts. Adobe Bridge SDK & Scripting guides for developers | Adobe I/O

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2024 May 08, 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 Screenshot 2024-05-08 at 2.46.21 PM.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2024 May 08, 2024

Look at the error. You are running it over and over and trying to create the same menu item. This script creates menu and contextual menu items, use those to invoke the actual process.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2024 May 08, 2024

The error message isn't there anymore, but when I go to Rename, nothing happens. Screenshot 2024-05-08 at 4.41.51 PM.pngexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2024 May 09, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 09, 2024 May 09, 2024

Yes, I use both Bridge 2023 and 2024 and the script does not work. Unfortunately I do not have any scripting skills, is there another script floating around that does the same thing this older script does, in particular this part: "this is a modified version that will accept an input and rename selected files based on that." That is what is needed!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2024 May 09, 2024

Does Batch Rename work for this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 09, 2024 May 09, 2024

The Batch Rename tool in the latest versions of Bridge do not have the capability, no. What I am trying to do is batch rename selected files in Bridge that I have manually arranged in the order I like within the content panel (50-100+ at a time) to numeric 8 digit IDs. These IDs are not always generated in alphanumerical order, which is why I cannot use the native Batch Rename tools in Bridge. The original images also have their own internal naming schema, it varies on the vendor I am receiving them from. This is why I just want a simple one to one batch rename tool: I have the images selected in Bridge, I have the option to paste the new IDs into the "input", and then the images are renamed to the IDs. It would also be helpful if this script would preserve the original filename in metadata (this is currently available in the native Bridge batch rename tool) but not absolutely necessary...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines