Skip to main content
Inspiring
October 19, 2017
Question

Bridge Batch Rename Add Suffix w Regular Expression?

  • October 19, 2017
  • 2 replies
  • 2383 views

So the situation is I have bought a huge texture bundle from Go Media, and all the files are named something like:

gma_tex_set05_clouds_01.JPG

gma_tex_set05_clouds_02.JPG (continuing through "filename"_03 -_30)

I want to rename them with the following structure:

clouds_01_gma.JPG

clouds_02_gma.JPG ( etc including "filename"_03.- _30)

So, I can do this but using 2 operations and I want to get it done in one operation.

I'm relatively new to Regular Expressions and String Substitution, but with a little research and a cheat sheet, I got MOST of what I need, but am still stuck on one point. I can't seem to get the "_gma" added at the END of the file but BEFORE the .jpg extension if using regular expressions to remove the first part (gma_tex_set05_). I found multiple ways to remove "gma_tex_set05_", including:

(in ALL instances below, the "Use Regular Expression" and "Replace All" checkboxes are CHECKED)

New Filenames:

String Substitution > Original Filename

Find: gma_tex_set05_

Replace: with (leave blank)

New Filenames:

String Substitution > Original Filename

Find: ^gma_tex_set05_

Replace: with (leave blank)

New Filenames:

String Substitution > Original Filename

Find: ((gma_tex_set05_))

Replace: with (leave blank)

New Filenames:

String Substitution > Original Filename

Find: ^.{14}

Replace: with (leave blank)

...etc. You get it... there are multiple ways to REMOVE the first part.

Now, in a separate operation, one NOT using RegEx, I can add the suffix "_gma" very easily.

New Filenames:

Current Filename > Name > Original Case

Text: _gma

EASY. BUT, I can't seem to COMBINE these functions in one operation to strip the "gma_tex_set05_" while simultaneously ADDING "_gma" BEFORE the .JPG suffix. I make the BEFORE distinction because I CAN add "_gma", but ONLY AFTER the .jpg extension:

New Filenames:

String Substitution > Original Filename

Find: ((gma_tex_set05_))

Replace: with (leave blank)

Text > _gma

Result = clouds_01.JPG_gma

However, when I FINALLY found some combination where the "Preview: Current Filename / New Filename" area shows what I'm trying to achieve, which is "clouds_01_gma.JPG", when I try to run it, it says "The regular expression is invalid."

New Filename:

String Substitution > Original Filename

Find: gma_tex_set05_

Replace: (leave blank)

String Substitution > Intermediate Filename

Find: (\....)

Replace: _gma

Run = The regular expression is invalid.

I've tried for 2 days and just can't seem to make it work. Again, I'm new to RegEx, so I don't know if it's me just not understanding a certain principal, or if trying to combine these 2 operations into 1 operation is just not possible. Any Ideas?

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
January 16, 2019

An old topic, but still worthy of a reply for others in a similar situation...

There are of course many suitable regular expression find/replace variations:

(.+_?)(clouds_\d+)(.JPG)

$2_gma$3

(.+_?)(clouds_\d+)(\.[^.]*$)

$2_gma$3

(?:.+_?)(clouds_\d+)(.JPG)

$1_gma$2

Mykill GAuthor
Inspiring
October 19, 2017

BTW, I downloaded a Trial of "A Better Finder Renamer 10" and it worked perfectly, I'm just hoping I don't have to spend the $20 and can figure it out inside Bridge.