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

Batch rename - help with specific rules

Community Beginner ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

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

TOPICS
Batch , How to

Views

184

Translate

Translate

Report

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

Community Expert , Jul 08, 2024 Jul 08, 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)

Votes

Translate

Translate
LEGEND ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

btw i'm an absolute beginner when it comes to this topic, so i dont know (regex) or how to use it 🙂

 

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

The simplest way would just be to enter the changes manually using String Substitution.

"_xx_xx" replace with "" (blank)

and

"_xx_xx" plus intermediate filename

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

unfortunately this doesn't work.
what i want is to move the territory code from back to the front of the filename:
 
ADOBE-12345_summer20_TestTest_carousel_xx_xx.png
to
xx_xx_ADOBE-12345_summer20_TestTest_carousel.png



Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Did you even lookup regular expressions? There is a clear pattern, and you just have to use the carot symbol to denote start of line. When you want to reverse this, $ indicates end of line.


Screenshot 2024-07-08 124111.png

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

Oh now i understand! Thank you, this is good start. Thank you

So i need to make a preset per territory code.
or is there a way to say ...."whatever is _*_* move to front and write it *_*_ "

then it wouldn't matter if it's de_de_ or fr_fr_ and so on

PS: im also playing around with MacOS Automator and stuck with the same issue. As soon as i add a second terroritory to the automation it goes crazy

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

A dot denotes any single character. So underscore dot dot, for example.

Take a look at some of the extensive info online.

https://www.regular-expressions.info/

Votes

Translate

Translate

Report

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

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)

Votes

Translate

Translate

Report

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 ,
Jul 09, 2024 Jul 09, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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 ,
Jul 09, 2024 Jul 09, 2024

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

Translate

Translate

Report

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