View Single Post
Old 06-11-2010, 11:54 PM   #59
TreborPugly
Member
TreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-booksTreborPugly has learned how to read e-books
 
Posts: 13
Karma: 954
Join Date: Jun 2010
Device: Mobipocket reader on Blackberry, XO using FBreader, Kindle
Thumbs down

Hi. I've been using Calibre for a few weeks and I'm really enjoying it.

I adopted a regular expression for Adding from this thread that does a great job for my files:

Code:
^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?((?P<series>[^0-9\-]+)(\s*-\s*)?(?P<series_index>[0-9.]+)\s*-\s*)?(?P<title>[^\-_0-9]+)
However, I have some files that are zipped, and the file name includes the format of the file inside the zip, like so:

Author name - Book title (htm).zip

So this will get imported with "Book title (htm)" as the title, rather than just "Book title". Then I have to manually merge things. The parenthesis might be (htm), or (rtf), or (txt), etc... I can get it to ignore the parenthesis by adding a [(] to the end of my regex, but then that breaks the adding for files that don't have a ( in them.

I'm new to regex, and I've done some reading of reference suggested from inside of Calibre (which is how I learned enough to put my little addition on), but I've been trying to figure out a way to use the | operator unsucessfully.

I'd be pleased with any solution that works, and if you have the time a brief description of why it works.

My expectation is that I want to match ( or nothing, but not sure how to do the nothing. ie, is there some way to tell it to start over if a match fails?

Thanks in advance.
TreborPugly is offline