Change order in book name

A swapping-ground for Regular Expression syntax

Change order in book name

Postby mamaijee » Mon Jan 27, 2014 4:01 pm

I am looking to change file names pf ebooks in Window Explorer ie

If the file name is in this order Author Name - ebook name (series name) eg Sandra White - All Soups (Microwave Cooking # 2)

where (Microwave Cooking # 2) is the series name,
I want to move the series name before the name of the book "All Soups" and the "(" to be replaced by "[" so that it looks like this:

Sandra White - [Microwave Cooking # 2] - All Soups
author name - [series name] - name of ebook

I dont know if this can be done. I dont have a clue about RegExp

Any help would be very appreciated.

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

Regex Group Reordering

Postby truth » Tue Jan 28, 2014 2:06 pm

1Regex match/replace:
(.+ - )(.+) \((.+)\)$
\1[\3] - \2

Match/Rename as below:
AuthorName - BookName (SeriesName)
AuthorName - [SeriesName] - BookName

It assumes a final Space-Space separates AuthorName from BookName.
The $ ensures that only files ending as Space(text) are matched for renaming.
If not always true, or you've other concerns, just post back with details/examples.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Change order in book name

Postby mamaijee » Wed Jan 29, 2014 5:39 pm

Thank u very much
Will give it a try and get back to you
Best wishes and do appreciate your help
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Re: Regex Group Reordering

Postby mamaijee » Wed Jan 29, 2014 7:52 pm

It works like a charm. Thank you so much.
May I tweak my original format a bit please to further help?
What if the filename is Sandra White - All Soups (Microwave Cooking # 2) (AM) where the (AM) at the end could be small or caps and if I want it to remain right at the end of the file name to read after regex like this :

Sandra White - [Microwave Cooking # 2] - All Soups (AM)

Is this possible too?

Many thanks in advance
Meher
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Regex Group Reordering

Postby truth » Thu Jan 30, 2014 9:52 am

IF you're looking for 1 regex to cover both conditions, try:
1Regex match/replace:
(.* - )(.+?) \(([^(]*)\)(.*)
\1[\3] - \2\4

You lose the mandate of how filenames must end, but its still fairly specific.
This one preserves all text after the 1st ) and leaves it in-place, so it covers:
Author - Book (Series) ----------> Author - [Series] - Book
Author - Book (Series) (AM) ----> Author - [Series] - Book (AM)

I'd also use 12Filters=* !*[* to prevent touching previously-renamed files with [ in them.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Change order in book name

Postby mamaijee » Thu Jan 30, 2014 6:01 pm

Many many thawnks.
Will give it a try and get back to you
Best wishes
Meher
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am

Re: Change order in book name

Postby mamaijee » Fri Jan 31, 2014 8:09 pm

I tried the revised one and it worked absolutely. You are brilliant!!!
You have saved me so much time you have no idea
Many many thanks :lol: :lol: :lol: :lol:
Best wishes
Meher
mamaijee
 
Posts: 33
Joined: Sat Apr 30, 2011 5:17 am


Return to Regular Expressions


cron