Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 06-16-2013, 01:24 AM   #1
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
More help needed: regex for add books

There are 2 questions, question 2 being the ideal situation..

Question 1:
If the book has no series, the file format is
author - title
If it does have series, the current format is
author - [series] [series_number] title

If I use this regex
(?P<author>.+) - \[(?P<series>.+)\] \[(?P<series_index>.+)\] (?P<title>[^_]+)
it works if there is a series, but not of there isn't.

How do I fix this?

Question 2:
I would prefer file format to be
author - [series series_number] title
But what if the series name is say Oceans 11, and the book is number 3 in the series. We'd have
author - [Oceans 11 03] - title
This requires a complicated regex, which is entirely beyond me.
macnab69 is offline   Reply With Quote
Old 06-16-2013, 01:49 AM   #2
gabby98
Wizard
gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.
 
gabby98's Avatar
 
Posts: 1,751
Karma: 2667650
Join Date: Jul 2012
Device: Android, Nook Simple Touch, Nook Color, ..., Glo
And you want this for adding books or saving to disk?

There should be something you can do with the bracket as the trigger, but I'm sleepy
and not of very much use atm. So I'll check back tomorrow and see if anyone else beat me to it.
gabby98 is offline   Reply With Quote
Advert
Old 06-16-2013, 01:55 AM   #3
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
This is for adding - got saving to disk cracked (thanks to your inspiration.) have a good sleep.
macnab69 is offline   Reply With Quote
Old 06-16-2013, 06:53 AM   #4
Sabardeyn
Guru
Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.
 
Sabardeyn's Avatar
 
Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
Ok, it's late and I'm not sure I'm exactly answering your question... but take a look at my post in the Tyrannosaurus Regex topic.

While the topic is very old, the complex regex works extremely well and should do what you want. It has the added benefit of having a cursory explanation of which clump of regex is doing what. It doesn't (unfortunately) offer a fully detailed explanation as it's the combined effort of multiple people - I was simply the person to string together the bits and pieces.

The only catch that I see immediately is that it depends on " - " (space dash space) being the delimiter between author/series info and series info/title. This is mandatory to differentiate the series info out from the rest - particularly in an "Oceans 11" type of series name situation.

I have seen simpler regex variants that can produce somewhat similar results - but not exactly similar. One difference I remember dealt with having L33t5p34k (leetspeak) within the mix. But all of this is noted in the topic.

(Just in case... You might be able to use a bulk filename utility to add " - " if needed to any existing files. Check any freeware website for viable choices. Rename-It! is my main tool on Windows XP & 7. Haven't tried it on Win8.)

Last edited by Sabardeyn; 06-16-2013 at 06:57 AM. Reason: Additional comment.
Sabardeyn is offline   Reply With Quote
Old 06-16-2013, 09:19 AM   #5
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
Thumbs up

Been using Bulk Rename Utility for years - excellent piece of software.

The regex works well, even handling the Oceans 11 scenario. Thanks.

I'll print out the regex and use coloured highlighters to mark off the sections and see if I can change it to use my bracket system. If successful, I will add it to that thread.
macnab69 is offline   Reply With Quote
Advert
Old 06-17-2013, 12:33 AM   #6
gabby98
Wizard
gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.
 
gabby98's Avatar
 
Posts: 1,751
Karma: 2667650
Join Date: Jul 2012
Device: Android, Nook Simple Touch, Nook Color, ..., Glo
OK..checking in after a long day (sorry so late) but let me know if you never found what you needed and I'll try to be of useful assistance in the light of day
gabby98 is offline   Reply With Quote
Old 06-17-2013, 12:44 AM   #7
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Quote:
Originally Posted by macnab69 View Post
Been using Bulk Rename Utility for years - excellent piece of software.

The regex works well, even handling the Oceans 11 scenario. Thanks.

I'll print out the regex and use coloured highlighters to mark off the sections and see if I can change it to use my bracket system. If successful, I will add it to that thread.
You might also want to look at the Quick Preferences plugin. In addition to allowing you to quickly change most all Add books preferences, It allows you to maintain and quickly switch between multiple reg expressions for Add books.
DoctorOhh is offline   Reply With Quote
Old 06-17-2013, 01:33 AM   #8
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
Thanks for the help everyone. The Quick Preferences plug-in is ideal for me - can have different filename styles without having to climb in with Bulk Rename Utility. The Swap Author Names is also useful.

Does anybody have an opinion on file-names with underscores instead of spaces, or is that best solved with Bulk Rename?
macnab69 is offline   Reply With Quote
Old 06-17-2013, 01:58 AM   #9
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
If anybody finds this useful:

This regex will accept both of these formats:
author - title
author - [series series_index] title

Regex:
Code:
^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s)?(?P<title>[^(]+)(?:\(.*\))?
macnab69 is offline   Reply With Quote
Old 06-17-2013, 08:02 AM   #10
Sabardeyn
Guru
Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.
 
Sabardeyn's Avatar
 
Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
I'm glad to learn that my suggestion was helpful to you. And better still that you were able to alter it to fit your needs and re-posted it.


BTW, a forum related tip: Found a gem of wisdom in a thread but you cannot make use of it this instant? Use the Thread Tools>Subscribe to this Thread drop down menu option (top of page) to keep the thread title and link in your User Control Panel. If used sparingly, it's a great way to "bookmark" important threads.
Sabardeyn is offline   Reply With Quote
Old 06-17-2013, 08:25 AM   #11
macnab69
Zealot
macnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toysmacnab69 shares his or her toys
 
Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
Good tip.
macnab69 is offline   Reply With Quote
Old 06-17-2013, 12:15 PM   #12
gabby98
Wizard
gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.gabby98 ought to be getting tired of karma fortunes by now.
 
gabby98's Avatar
 
Posts: 1,751
Karma: 2667650
Join Date: Jul 2012
Device: Android, Nook Simple Touch, Nook Color, ..., Glo
glad you found what you needed!
gabby98 is offline   Reply With Quote
Reply

Tags
add book, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: regex for add books macnab69 Library Management 4 06-16-2013 01:53 AM
My RegEx works in Test but not for Add Books kanigetts Library Management 11 09-18-2012 02:59 AM
Want RegEx to add books to Calibre huon Library Management 0 02-02-2012 12:52 AM
Add Books - Regex Help Please nynaevelan Calibre 2 08-16-2011 01:30 PM
understandng the sample add books regex cybmole Library Management 11 03-02-2011 06:08 AM


All times are GMT -4. The time now is 08:41 PM.


MobileRead.com is a privately owned, operated and funded community.