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

Bridge 2022 - Batch Rename Using Regex

Community Beginner ,
Dec 02, 2021 Dec 02, 2021

Hello, 

I made a post before - but I realized that I did not offer enough information and I finally figured out a bit more how to do what I am trying to do. Here is my work-flow with Bridge for running my batch rename / ideal script.

 

Step 1 - Select All Images (Control+A or Command+A)

Step 2 - Sort by Rating - Ascending Order (all of my images are ranked by either 1 star, 2 star or 3 star, I use this as a way to pick which image is the b image)

Step 3 - Run AUTO_RENAME_01 (this is just what I call my saved batch rename setting) using the attached screenshot settings. 

FIND: - ^(.{17})(.*) REPLACE: $1_bSTRING-SUBSTITUTION_01.pngexpand image

What this is doing is basically renaming all of my images. 

From the following;

111647050986_001 BLOUSE_0490.jpg
0111647050986_001 BLOUSE_0491.jpg
0111647050986_001 BLOUSE_0492.jpg
0112439780127_080 SHRUG_0869.jpg
0112439780127_080 SHRUG_0870.jpg
0112439780127_080 SHRUG_0871.jpg

To the following;

0111647050986_001_b.jpg

0111647050986_001_b (1).jpg
0111647050986_001_b (2).jpg

0112439780127_080_b.jpg
0112439780127_080_b (1).jpg
0112439780127_080_b (2).jpg

 

Step 4 - Run AUTO_RENAME_02 (this is what I call my secondary batch rename) and its just a series of String Substitutions; as following. 

String Substitution - Original Filename

Find b (1) Replace with d

String Substitution - Intermediate Filename

Find b (2) Replace with e

String Substitution - Intermediate Filename

Find b (3) Replace with f

String Substitution - Intermediate Filename

Find b (4) Replace with g

String Substitution - Intermediate Filename

Find b (5) Replace with h

This is the end of it since I never use more images with the same code that would result in anything past h.

SECOND-RENAME_03.pngexpand image

What this is doing is basically renaming all of my images a second time.

From the following;

0111647050986_001_b.jpg

0111647050986_001_b (1).jpg
0111647050986_001_b (2).jpg

0112439780127_080_b.jpg

0112439780127_080_b (1).jpg
0112439780127_080_b (2).jpg

To the following;

0111647050986_001_b.jpg
0111647050986_001_d.jpg
0111647050986_001_e.jpg
0112439780127_080_b.jpg
0112439780127_080_d.jpg
0112439780127_080_e.jpg

 

Here are two screenshots of the final result. Since the result is sort by rating - it shows all of the b first then e then etc. However if I re-order back to sort by filename (on the second screenshot) you can see the result is that each unique 17 digit code is followed by _d _e _f _g 

RENAMED_SORT_RATING_01.pngexpand image

RENAMED_SORT_FILENAME_02.pngexpand image

 

I hope this makes sense. My question is - will I be able to script this process? Either by writing a script that says Run AUTO_RENAMER_01 and when finished Run AUTO_RENAMER_02 (I feel like this would be the easiest way?) or would I be able to script something that uses that regex + the rating in the meta-data of the image to detone the name? 

Rating 1 - rename _b 

Rating 2 - rename _d 

Any other rating name sequentially from d so 

Rating 3 - rename e, f,g,h

etc. 

 

I hope this makes sense, I am very begginer level when it comes to scripting and this is something that I would usually get an idea on how to do via using PhotoShop script listener and studying the code it generates, but I cannot seem to find a listener version for bridge or the documentation with codes without access to the SDK / Console)

TOPICS
Batch , How to , Metadata , Scripting
2.0K
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 ,
Dec 03, 2021 Dec 03, 2021

Were you able to run the code (with instruction given) I made in other thread?

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 ,
Dec 03, 2021 Dec 03, 2021

I saved it down as a jsx as it was not showing up on the scrips list and still could not get it to show up. I get it to show up on the preferences but I can't seem to run it! But again, my knowled of scripting with Bridge seems to be limited. Let me re-check the other thread and see if I missed something in terms of  getting it to run.

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 ,
Dec 04, 2021 Dec 04, 2021
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 ,
Dec 04, 2021 Dec 04, 2021
LATEST

Hey @Kukurykus,

 

I went through the code and made it work, thank you for that - it taught me how to do the function and put it in the menu as well which is very useful for any future things I want to add! It is very fascinating what it is doing but I do not think its quite doing what I need it to do. It is currently taking 1 file and duplicating it x-amount of times and renaming it as you stated 'def' which I changed to 'defgh' and it worked. So I have learned a lot from it. I think my explonation is a bit more clear on the other post. 

My next question is - am I able to select for example 6 images - and rename them all using REGEX ^(.{17})(.*) to extract the first 17 digits and rename them in a sequential order of b d e f g using the rating as sorting order for which one is b d e meaning star rating 1 = b, star rating 2 = d, star rating 3 = e f g, etc. 

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 ,
Dec 03, 2021 Dec 03, 2021

Why can't you just use the + sign to add another intermediate filename renaming set so that both of your separate rename steps are combined into one rename?

 

Can you provide a screenshot or a download link to the two batch rename settings?

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 ,
Dec 03, 2021 Dec 03, 2021

Hi Stephen, 

 

When I tried that - I could not get it to work by building them into one but it could be that I just missed something? 

 

I have attached both of these and some sample jpgs that I use if that's helpful - not sure if we are allowed to use wetransfer? 

 

https://we.tl/t-LsYBWWwbyr

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 ,
Dec 03, 2021 Dec 03, 2021

I'll give it a look...

 

Edit: Ah, I see, you are intentionally creating duplicate filename clashes which result in a (1) or (2) etc. being created on disk, which you then leverage to create the 2nd step rename versions that use a d, e, f, g, h version. These (1) filenames are not generated in the intermediate filename.

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 ,
Dec 03, 2021 Dec 03, 2021

Yes, apologies if that was not clear by my explonation. I am only doing it that way because I do not know of a better way to do it. 

Essentially I need to extract the first 17 digits of all of the filenames - and rename them in sequenial order but b d e f instead of a b c d e f.

Not only that the only way I know to force the b file is by the star rating. So I force a order by star rating - forcing all 1 star to be b's - then all 2 star's to be e and all the rest to just follow after. Not sure if this helps make more sense of it or make more confusion 😄 

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