View Single Post
Old 01-29-2010, 07:20 PM   #1
Dysonco
Junior Member
Dysonco began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2010
Device: Sony PRS505
Help with the regular expression

Hi All,

New member of the forum, so hello everyone! I thought I'd kick off with a conundrum that I'm having trouble solving.

I'm a great fan of Calibre, its a great bit of software, I'm just having a little trouble configuring it to correctly identify the information from the filenames in my book collection.

All my books have their filenames in this format:

AuthorLastname, AuthorFirstnames - BookSeries SeriesNumber - BookTitle.FileExtension

I've tweaked the regular expression (mostly by trial and error as I'm most definately not a programmer) to this:

(?P<author>[^_]+) - (?P<series>[^_]+) - (?P<title>[^_]+)

Now this works fine on the filename example as above, but unfortunately fails when the BookSeries and SeriesNumber parts are missing (when its a single book and not a part of a series).

So for example:

Pratchett, Terry - Discworld 01 - The Colour Of Magic.pdf

Would work okay, but:

Pratchett, Terry - Strata.pdf

Wouldn't. I almost need a way to set the expression to realise that if theres only two groups to recognise that it is Author and Title and ignore the series bit.

Any suggestions from the gurus?

Many thanks,

Mike
Dysonco is offline   Reply With Quote