Page 1 of 1

RegEx rename: Replace last occurrence of dash

Posted: 11 Aug 2016 21:14
by TomPiXX
Hey community,

for now I'm using the really great "Bulk Rename Utility" to rename my files.
But I wish to have a smoother workflow so I think about using XYplorer to rename my files.

I have several files named TAG1 - TAG2 - TAG3 - TAG4,TAG5.xyz for example.
The TAGs after the last dash have to be in brackets and the last dash should be removed.

TAG1 - TAG2 - TAG3 - TAG4,TAG5.xyz
TAG1 - TAG2 - TAG3 (TAG4,TAG5).xyz

In the Bulk Rename Utility I'm using (.*) - (.*)$ for matching and \1 (\2) for replacing. But it's not RegEx compliant, so that won't work with XYplorer.
Could somebody help me out with a correct RegEx?


Thanks!

Tom

Re: RegEx rename: Replace last occurrence of dash

Posted: 11 Aug 2016 21:23
by highend

Code: Select all

(.*) - (.*)(\..*)$ > $1 ($2)$3
If we're talking about Rename Special - RegExp Rename...

or in a script?

Code: Select all

    $a = "TAG1 - TAG2 - TAG3 - TAG4,TAG5.xyz";
    text regexreplace($a, "(.*) - (.*)(\..*)$", "$1 ($2)$3");


Re: RegEx rename: Replace last occurrence of dash

Posted: 11 Aug 2016 21:29
by TomPiXX
Thanks, mate!