Rename

I bet you can do this with reg exp but i've never used them.

How can I rename the following files

01_artist_-first song(blah).mp3
02_artist
-second song(blah).mp3
03_artist
-third song(blah)_.mp3

to this

artist - first song
artist - second song
artist - third song

Thanks

Hello,

Someone will probably find a more elegant solution to this,
but I hammered out this one in a few minutes.

Old Name:
([0-9][0-9])(.*)(-)(.*)((.*)_)(.mp3)

New Name:
\2 - \4\6

I have to go now.
I'll check back in about 9 hours.

Zippo

That worked great, thanks. Not that I understood any of it.

In the interests of explaining Zippos RegEx:

Old Name:
([0-9][0-9])(.*)(-)(.*)((.*)_)(.mp3)

The above "old name" expression from left to right does...........

([0-9][0-9]_)
Represents 2 numerical digits on the left of the file name followed by an underscore. Because the expression is enclosed in () it can be referenced in the new name by \1. Since you did not want the numbers in the new name, \1 was not included in the new name

(.*)
Represents anything. Note that it too is enclosed in parenthesis and which means it can be referenced in the new name by \2 which Zippo does.

(-)
Represents just what it looks like, an underscore followed by a dash followed by another underscore. Again he enclosed it in parenthesis and it could have been referenced in the new name with a \3

(.*)
Represents anything. Note that it too is enclosed in parenthesis and can be referenced in the new name by \4 which Zippo does.

((.*))
Represents an underscore followed by an ( followed by anything followed by ) followed by another underscore. This match could have been represented in the new name by \5

(.mp3)
Represents the .mp3 file extension and was represented in the new name by \6

I very much enjoyed seeing (-) used legitimately in the forums. :slight_smile:

I'm looking forward to question which is solved by a regexp that includes (.Y.) :slight_smile: :slight_smile:

@Reck
I'm glad it works for you.
Listen to what John said and study the manual.

@John
Thanks John !

@Nudel
Yes,
I thought about it a while and I understand now.
I knew that all the while though.
That's why instinct told me to be careful.

Ever see any old Jenny Agutter DVDs ?
Walkabout,
Logan's Run,
China9 Liberty 37,
An American Werewolf in London ?

@all
Obviously Nudel is a very dynamic individual.
Not quite what I ever envisioned an Oxford grad to be.....

Zippo