How do I rearrange groups in file name?

A swapping-ground for Regular Expression syntax

How do I rearrange groups in file name?

Postby coyotewrw » Thu Mar 02, 2006 6:25 am

Hi! I have a problem that is beyond my skills, so hopefully someone can assist. I have some compilation albums with filenames like this:

[Album] - [Index] - [Artist] - [Song]

No Thanks! The '70s Punk Rebellion - 10 - Television - Little Johnny Jewel.mp3
No Thanks! The '70s Punk Rebellion - 11 - The Adverts - One Chord Wonders.mp3


I need to switch the [Artist] and [Index] parts, like this:

[Album] - [Artist] - [Index] - [Song]

No Thanks! The '70s Punk Rebellion - Television - 10 - Little Johnny Jewel.mp3
No Thanks! The '70s Punk Rebellion - The Adverts - 11 - One Chord Wonders.mp3

Thanks in advance for any advice!
Last edited by coyotewrw on Fri Mar 03, 2006 1:31 am, edited 1 time in total.
coyotewrw
 
Posts: 10
Joined: Thu Mar 02, 2006 6:08 am

Postby Stefan » Thu Mar 02, 2006 1:52 pm

First you have to split your file name in accurate defined groups
so you can reference to this goups later by the regex command '\#'
what means \1 for your first group, \2 for your second group and so on.
The groups are count from left to right in order you have defined them:
(group1)(group2)...


Search for groups of characters(.+) and use the '-' -sign as stop
like:
(.+) - (.+) - (.+) - (.+)

That means:
( = group start
. = any char
+ = one or more of the sign bevor{any char in this case}
) = group end

(group \1) - (group \2) - (group \3) - (group \4)
(No Thanks! The '70s Punk Rebellion) - (10) - (Television) - (Little Johnny Jewel).mp3



Then replace in order you want:

\1 - \3 - \2 - \4
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby Stefan » Thu Mar 02, 2006 6:06 pm

And, coyotewrw,

would you please modify the subject of your post to "replace groups in file name"
(or something like that in an better english :( )
so that other user find help too ?
THX
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby coyotewrw » Fri Mar 03, 2006 2:02 am

Thanks Stefan, that worked! And I clarified the topic title as requested :)

For my fellow noobs :P, here's a screenshot:
http://www.coyotelogic.com/pics/bulk_rename_example.jpg
coyotewrw
 
Posts: 10
Joined: Thu Mar 02, 2006 6:08 am


Return to Regular Expressions