Swap parts of name: Artist-Song to Song-Artist

A swapping-ground for Regular Expression syntax

Swap parts of name: Artist-Song to Song-Artist

Postby Stefan » Tue May 17, 2011 3:25 pm

Re: Getting help with Regular Expressions
post by CidiRAM » Tue May 17, 2011 12:48 pm
CidiRAM wrote:01 Eagles - Hotel California how to convert in: 01 Hotel California - Eagles
Thanks


FROM:
01 Eagles - Hotel California
TO:
01 Hotel California - Eagles

DO:
match one-or-more digits incl. following space ==> "(\d+ )" ==> "01 "
match then all till before an space-dash-space => "(.+) - " ==> "Eagles" + " - "
match the rest till the end ======> "(.+)" ====> "Hotel California"
All what is matched inside an (...) group can be used in replacement by using the "\1" signs.
Replace with match from group one, three, then two ==> "\1\3 - \2" adding new space-dash-space your own.


Use in BRU:
* test first with copies of your real files!
* this solution will only work on files like you have provided in your example.

RegEx(1)
Search: (\d+ )(.+) - (.+)
Repla: \1\3 - \2

* select a few or all files in "Name"-column to see the preview in "NewName"-column.
* if all went fine, press at [Rename]

HTH?
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Return to Regular Expressions