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-04-2016, 08:51 PM   #1
jecilop
Addict
jecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day now
 
Posts: 260
Karma: 139980
Join Date: Mar 2014
Device: Android
Help needed- RegExp for filename to metadata when adding books

SOLVED as of Post #4.

Hello,

The default regular expression for getting metadata from filenames on import is:
(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ?

I have tried adjusting this, but I cannot get it right. Searches related to my problem do not yield the needed answer.
I am trying to import filenames of the following format and want them to fill in the obvious fields.

John Doe - [Narnia World 01] - The Book's Name.epub

The test with the default expression above just yields the author with the rest as the filename. My adjustments result in invalid expressions or incorrect imports.

Can someone share the tweek to this so that files of this format will import as desired? Also, I'm hoping the adjustment will leave the following format as desired on import despite using a single regular expression.
John Doe - The Other Book's Name.epub


So using ONE regular expression for a group of files to be added:
The first book will import 4 types of metadata (author, series, series index, title).
The second book will import only 2 (author and title).

Help is definitely appreciated. I feel like what is default should work for this, but I get the symbols jumbled. I had a pretty good handle on regular expression awhile back, but I think I have to start over :-(

Attached is a screenshot of the Adding Books window showing the test with the default expression.
Attached Thumbnails
Click image for larger version

Name:	Transform title to metadata.JPG
Views:	141
Size:	59.3 KB
ID:	149201  

Last edited by jecilop; 06-07-2016 at 06:47 PM. Reason: Updated-Solved.
jecilop is offline   Reply With Quote
Old 06-05-2016, 03:11 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
How does this look?
The series/series_index section (with brackets properly accounted for) is surrounded in an optional non-capturing group.

Code:
(?P<author>[^_-]+) - (?:\[(?P<series>[^_0-9-]*) (?P<series_index>[0-9]*)\] - )?(?P<title>[^_].+)
eschwartz is offline   Reply With Quote
Advert
Old 06-05-2016, 06:38 PM   #3
jecilop
Addict
jecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day now
 
Posts: 260
Karma: 139980
Join Date: Mar 2014
Device: Android
Thank you!!
That worked perfectly.

I don't suppose you know how to make it work for series that involve decimals such as .5 or 2.8 or even 3.75.

I tested that (not thinking about it in my original post as being an issue), but the decimal acts as divisive text if in the file name thus greatly changing the import.

It worked fine for any integers, but I do not know how to modify to accept these.
jecilop is offline   Reply With Quote
Old 06-05-2016, 11:34 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Should be a simple matter of modifying the
Code:
(?P<series_index>[0-9]*)
section to say that the character set should include a period in addition to numbers.

So:
Code:
(?P<series_index>[.0-9]*)
...

AFAIK the period shouldn't do anything wonky re: filenames, unless of course the file has no extension -- which would mean the period there was declaring everything else to be the file extension.
Fortunately, that is rather unlikely.

Last edited by eschwartz; 06-05-2016 at 11:37 PM.
eschwartz is offline   Reply With Quote
Old 06-07-2016, 06:46 PM   #5
jecilop
Addict
jecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day nowjecilop will be dicovering the secret to cold fusion any day now
 
Posts: 260
Karma: 139980
Join Date: Mar 2014
Device: Android
Thanks again @eschwartz.

I'm still just barely a beginner on this code. I can put Excel formulas within formulas within formulas without a problem, but this one gets me.

You've given me more to learn from. I tried a website on Regex that you actually linked to on another post of mine a good while back, but it just didn't do it for me.
jecilop is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Books RegExp date/year) anonymust Library Management 5 11-08-2015 05:07 PM
calibre regexp for adding books garberw Library Management 9 08-29-2015 07:36 PM
Regexp for adding books failing nvcleemp Library Management 10 08-29-2015 02:23 AM
Regular Expression - Adding metadata from filename LMF Calibre 1 03-20-2012 06:46 PM
Little Help with Metadata from Filename needed plunderydoo Calibre 4 09-06-2009 08:34 AM


All times are GMT -4. The time now is 03:52 AM.


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