Moving part of a name

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Moving part of a name

Postby mamaijee » Sat Apr 30, 2011 5:26 am

I have a huge list of ebook files where the name of the book is first, followed by a "- "and then the name of the author eg

"All She Wrote - May Winter"

I would like to move the author to the begining of the file name followed by a - so it reads as

"May Winter - All She Wrote"

I dont know anything about Reg Expressions. Pls help me.

Thank you
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Re: Moving part of a name

Postby Stefan » Sat Apr 30, 2011 5:10 pm

mamaijee wrote:FROM:
"All She Wrote - May Winter"
TO:
"May Winter - All She Wrote"


RegEx(1)
MATCH: (.+) - (.+)
REPLACE: \2 - \1

Explanation:
Find all till an space followed by an dash and an another space ===> "(.+) - "
Then find all as the rest till the end ===> "(.+)"
The parentheses (...) means "group what is matched by the regex for back-reference".
You can access what is matched by the first (...)-group with an "\1"
So in the replacement just use "\2" first, add space and dash yourself as you like and end with an "\1"
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Moving part of a name

Postby mamaijee » Sun May 08, 2011 11:46 pm

Thank you for your help - It worked
Mamaijee
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Re: Moving part of a name

Postby mamaijee » Mon May 09, 2011 5:42 pm

Please could u help me a bit further also

If the file name is "Young, Amanda - Furtive Liaison" and I would like to change the second word to be first and the comma dropped to read as "Amanda Young - Furtive Liaison". Pls could you help with the Regex.

Thank u very much.
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Re: Moving part of a name

Postby Stefan » Mon May 09, 2011 8:46 pm

mamaijee wrote:FROM:
"Young, Amanda - Furtive Liaison"
TO:
"Amanda Young - Furtive Liaison"


Match all signs till an coma ==> "(.+)," ====> "Young," ====> inside the backreference group No.1 => "Young"
followed by an space and one-or-more signs ==> " (.+)" ====> " Amanda" ====> inside the backreference group No.2 => "Amanda"
followed by an space and an dash and an space and one-or-more signs till the end ==> "( - .+)" ====> " - Furtive Liaison" => group No.3

Then replace with what is matched in group No.2, an space, and then No.1 and then No.3:

RegEx(1)
MATCH: (.+), (.+)( - .+)
REPLACE: \2 \1\3


Untested, maybe we have to add or remove an space here or there?
And "of course" works only if there are only ONE coma and ONE dash in the whole name.


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

Re: Moving part of a name

Postby mamaijee » Tue May 10, 2011 4:50 pm

Thank you very much for taking the time for such a detailed reply.

Do appreciate the help.

Mamaijee :D
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am


Return to BRU Support