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 02-02-2012, 12:52 AM   #1
huon
Junior Member
huon began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Feb 2012
Location: Canberra, Australia
Device: Kindle
Want RegEx to add books to Calibre

Hello

I’m unable to get my RegEx to add books to Calibre, and will be very grateful for assistance.

Using Excel and DOS I’ve renamed all the files to have the following format: <author> _ <title> (<series> <series_index>).<ext> eg ‘Lee Child _ Without Fail (Jack Reacher 06).epub’.

ie AUTHOR and TITLE are separated by “ _ ” ie SPACE UNDERSCORE SPACE.
SERIES and SERIES_INDEX are separated by “ ” ie SPACE, and are enclosed within brackets “( … )”.

AUTHOR and TITLE are mandatory.
SERIES and SERIES_INDEX are optional, and SERIES may occur without SERIES_INDEX.

The filename may also end (ie before .ext) with a string in square brackets and preceded by a space eg <author> _ <title> [HTML].<ext>. It may be used with compressed files (.zip, .rar) to show the file type of their contents eg Alice Byron - The Bombmaker [html, jpg].rar. This information is not added to Calibre.

I want a RegEx to capture AUTHOR, TITLE, SERIES and SERIES_INDEX.
I think the 6 examples in the following table cover all possibilities:
Filename Series # HTML
1 Ace Atkins _ Infamous.epub - - -
2 Alice Byron _ The Bombmaker [html].rar - - Yes
3 Brian Adams _ A Disaster (Pee Wee).lit Yes - -
4 Beth Brown _ Bombs Away (Ace Bly) [html, jpg].rar Yes - Yes
5 Chad Altman _ Noon Today (Jay Wells 04).epub Yes Yes -
6 Chloe Beck _ Lullaby Town (Adam Eve 03) [html].rar Yes Yes Yes

In trying to understand regular expressions I wrote the attached PythonCodingInCalibre_v0-1.doc, but I’m missing something.

(?P<author>[^-]+) - (?P<title>[^[]+) [(](?P<series>.*) (?P<series_index>\d*)[)] works with files 5 and 6 (in the above table) but not files 1-4,though I had to change the AUTHOR/TITLE separator from an underscore to a hyphen as I couldn’t get the underscore to work. Is there something special about the underscore?

Regards, David
Attached Files
File Type: doc PythonCodingInCalibre_v0-1.doc (92.0 KB, 355 views)
huon is offline   Reply With Quote
Reply

Tags
add books, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Book Regex to Custom field adept22 Library Management 3 10-07-2014 07:33 PM
Add Books - Regex Help Please nynaevelan Calibre 2 08-16-2011 01:30 PM
Problem with "Add Books" regex wygit Library Management 9 07-24-2011 12:24 PM
understandng the sample add books regex cybmole Library Management 11 03-02-2011 06:08 AM
Add book regex no longer works magphil Calibre 3 03-24-2010 03:40 PM


All times are GMT -4. The time now is 09:18 AM.


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