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
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)
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.
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
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 🙂
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
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
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.
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
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.
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)
Copy link to clipboard
Copied
You're my hero, Stephen!
Absolute perfection! Thank you so much
Copy link to clipboard
Copied
You're welcome!