Skip to main content
Participating Frequently
July 8, 2024
Answered

Batch rename - help with specific rules

Hi community,

i've tried everything but i can't find the correct sollution for my very specific problem.
Our client uses a naming guideline for their files.
For some reason they've added the country code to the end of the file name.
For my work i need it in the front but also i need a rule to reverse it when i want to deliver the files.

For example

File name is:

ADOBE-12345_summer20_TestTest_carousel_All_All.png

File name should be:
All_All_ADOBE-12345_summer20_TestTest_carousel.png

Can someone help me with a step by step guide on how to set the rules to achieve that.
And also another set of rules on how to change the naming back for delivery.

Thank you!

Alan

This topic is closed to new replies. Start a new post to keep the conversation going.
Stephen Marsh
Stephen MarshCorrect answer
Community Expert
July 9, 2024

Using the regular expression string substitution option with capture groups:

 

Find: 

(.+)(_)(.+_.+)(\.[^\.]+$)

 

Replace:

$3_$1$4

 

Note: Although it is possible to preserve the original filename and restore the original filename via metadata, this doesn't work with all image formats (i.e. TGA, GIF). So, to convert back to the original:

 

Find:

(\w+)(_)(.+)(\.[^\.]+$)

 

Replace:

$3_$1$4

 

Hope this helps!

 

(original post updated/corrected)

11 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
July 9, 2024

Using the regular expression string substitution option with capture groups:

 

Find: 

(.+)(_)(.+_.+)(\.[^\.]+$)

 

Replace:

$3_$1$4

 

Note: Although it is possible to preserve the original filename and restore the original filename via metadata, this doesn't work with all image formats (i.e. TGA, GIF). So, to convert back to the original:

 

Find:

(\w+)(_)(.+)(\.[^\.]+$)

 

Replace:

$3_$1$4

 

Hope this helps!

 

(original post updated/corrected)

Translate
Participating Frequently
July 9, 2024

You're my hero, Stephen! 
Absolute perfection! Thank you so much

Translate
Stephen Marsh
Community Expert
Community Expert
July 9, 2024

You're welcome!

Translate
Legend
July 8, 2024

Is the pattern consistent for every file? Or does it vary?

You can use regular expressions (regex) for this but you have to have a pattern to follow.

Translate
Participating Frequently
July 8, 2024

the setup for the naming is always the same:

ADOBE-12345_summer20_TestTest_carousel_All_All.png
the bold parts change from project to project
the italic part changes depending on the territory

example:

ADOBE-16665_winter80_TestTestTwo_carousel_de_de.png
ADOBE-18745_fall32_TestOne_Interstitial_fr_fr.png

Translate