View Single Post
Old 12-28-2010, 05:21 PM   #3
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,731
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Quote:
Originally Posted by ejjenkins View Post
I have read through most of the threads for Calibre and regular expressions, I am at a loss.

I have a lot of books that are all saved in the exact same format and I want to be able to extract the metadata from the filenames. Here are a couple of examples:

Adams, Robert,Castaways In Time,01,Castaways in Time.txt
Anderson, Kevin J.,Game Earth,01,Game Earth.txt

All of them are: Author Last Name, First Name, Series Name, Series Index, and Title

If there is no series or series index, the comma will still be there, for example:

Aldiss, Brian W.,,,The Dark Light Years.txt
Anderson, Poul,,,Brainwave.txt

I know this is probably pretty easy and straightforward, but I can't seem to get my brain around this.
Try this regex:
^(?P<author>([^,]+,[^,]+)),(?P<series>[^,]*),(?P<series_index>[^,]*),(?P<title>[^,]*)
kiwidude is offline   Reply With Quote