#1 2016-10-06 21:16

dodgy
Member
Registered: 2010-04-01
Posts: 9

Rename final "-" to "(" ... (help with RegEx)

Hi,

I've a lot of MP3s that I've ripped from mix CDs in the following format:

01 - Artist - Track - Mix.mp3

They are mixed in with tracks in the following format:

02 - Artist - Track.mp3

Is it possible to write an expression that would rename the first to:

01 - Artist - Track (Mix).mp3

But leave the second file alone?

Any help most appreciated.

Offline

#2 2016-10-06 21:43

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Rename final "-" to "(" ... (help with RegEx)

How do you determine which "-" to replace with "(" ?

Is it always the 3rd or later occurrence of "-", or whichever one as long as it ends with "Mix"?

More examples might help too.

Offline

#3 2016-10-06 21:56

dodgy
Member
Registered: 2010-04-01
Posts: 9

Re: Rename final "-" to "(" ... (help with RegEx)

Hi

I suppose to cover artists who may have - in the name it would be as follows:

If there is more than one "-<space>" then replace the right-most one with "(" then terminate the filename with a ")"

I can gather some real examples in the morning - thanks for the help (and an awesome program)

Offline

#4 2016-10-06 22:08

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: Rename final "-" to "(" ... (help with RegEx)

dodgy wrote:

If there is more than one "-<space>" then replace the right-most one with "(" then terminate the filename with a ")"

I presume you meant if there is more than two "-<space>", otherwise even "02 - Artist - Track.mp3" will get replaced.

So, here is a RegEx rule:

Replace expression "\A(.*)\s+-\s+(.*)\s+-\s+(.*)\s+-\s+(.*)\Z" with "$1 - $2 - $3 ($4)" (skip extension)

Input:

00 - Artist.mp3
01 - Artist - Track.mp3
02 - Artist - Track - Mix.mp3
03 - Artist - Track - Track - Mix.mp3
04 - Artist - Track - Track - Track - Mix.mp3

Output:

00 - Artist.mp3
01 - Artist - Track.mp3
02 - Artist - Track (Mix).mp3
03 - Artist - Track - Track (Mix).mp3
04 - Artist - Track - Track - Track (Mix).mp3

Offline

#5 2016-10-07 09:16

dodgy
Member
Registered: 2010-04-01
Posts: 9

Re: Rename final "-" to "(" ... (help with RegEx)

That worked perfectly - thanks very much!

Offline

Board footer

Powered by FluxBB