Hello, I wish to rename files, I have success but some names are cut of 2 last same characters (BB, CC or GG). What is bad in my command please?
Image: http://www.onweb.cz/regex.jpg
Mass rename files with Regex
Moderators: Hacker, petermad, Stefan2, white
Re: Mass rename files with Regex
Hi and welcome.
Because you have told TC to remove doubled parts (BB, CC or GG) with your expression: (.*)\1
That more complicate expression is not need at all for your issue and TCs regex engine, just use only -.+
And it would be fine to post the names and the expression additionally as text here too, so others can use that for testing what's going on.
Because you have told TC to remove doubled parts (BB, CC or GG) with your expression: (.*)\1
That more complicate expression is not need at all for your issue and TCs regex engine, just use only -.+
And it would be fine to post the names and the expression additionally as text here too, so others can use that for testing what's going on.
Re: Mass rename files with Regex
I would like to rename (cut) file name just to first dash. I use command (.*)\1-(.*)
It works fine for names like PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg but not for PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
result (bad): PH0609_.jpg
correct result: PH0609_BB.jpg
It works fine for names like PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg but not for PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
result (bad): PH0609_.jpg
correct result: PH0609_BB.jpg
Re: Mass rename files with Regex
Yes, as I wrote
FROM:
PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg
PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
TO:
PH0609_BE.jpg
PH0609_BB.jpg
USE MRT (multi rename tool):
Search : -.+
Replace:<Clear>
[_]E
[x]RegEx
Explanation:
-.+ >>>>> match anything one-ore-more times from first hyphen greedy to the end
You have shown in your linked picture:
FROM:
PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg
PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
TO:
PH0609_BE.jpg
PH0609_.jpg
Search : (.*)\1-(.*)
Replace:<Clear>
[_]E
[x]RegEx
Explanation:
(.*)- >>>>> match anything until an hyphen
(.*)\1- >>> match anything which arise twice (doubled like "BB") until an hyphen
(.*)\1-(.*)> match anything which arise twice until an hyphen and then greedy the rest
And you have used the star-multiplicator * which means none-or-more occurrences.
So if (.*) match nothing and \1 means double "those nothing", it is just ignored.
FROM:
PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg
PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
TO:
PH0609_BE.jpg
PH0609_BB.jpg
USE MRT (multi rename tool):
Search : -.+
Replace:<Clear>
[_]E
[x]RegEx
Explanation:
-.+ >>>>> match anything one-ore-more times from first hyphen greedy to the end
You have shown in your linked picture:
FROM:
PH0609_BE-EYESHADOW-LUMIERE-BLUE-EMERALD.jpg
PH0609_BB-EYESHADOW-LUMIERE-BLAZING-BLUE.jpg
TO:
PH0609_BE.jpg
PH0609_.jpg
Search : (.*)\1-(.*)
Replace:<Clear>
[_]E
[x]RegEx
Explanation:
(.*)- >>>>> match anything until an hyphen
(.*)\1- >>> match anything which arise twice (doubled like "BB") until an hyphen
(.*)\1-(.*)> match anything which arise twice until an hyphen and then greedy the rest
And you have used the star-multiplicator * which means none-or-more occurrences.
So if (.*) match nothing and \1 means double "those nothing", it is just ignored.
Re: Mass rename files with Regex
Thank you very much for help.