Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 03-25-2020, 03:47 PM   #1
jeffersonm
Member
jeffersonm began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jun 2017
Device: None
Regular Expression in Adding Books

Let me start out by apologizing for being a non-programmer!

I have a batch of files with the file name format:

"Publisher - Author - Title - Category.pdf"

I wish to import these files with the metadata being populated as Publisher=Publisher, Author=Author, Title=Title, and Category=Comments.

I have tried reading the tutorial and other posts online about how to format the regular expression for adding books, but frankly don't understand the nuances enough. I have tried playing with the test option and the expressions that pop up with the mouse rollover, but I can only seem to pick up the author and title.

Can anyone give me some help in creating this expression?

Thanks!

Jeff
jeffersonm is offline   Reply With Quote
Old 03-25-2020, 09:22 PM   #2
dunhill
Zealot
dunhill doesn't litterdunhill doesn't litterdunhill doesn't litter
 
dunhill's Avatar
 
Posts: 139
Karma: 242
Join Date: Sep 2017
Device: moon+ reader, kindle paperwhite
Have you tried the add book template as follows, to see if it works? ('P <Publicer>. +) - (? P <author> [^ _] +) - (? P <title>. +)
I do not think it is convenient for you to put the comments because they are infinite text fields. Try this waiting for a more accurate comment.
dunhill is offline   Reply With Quote
Advert
Old 03-26-2020, 06:59 AM   #3
jeffersonm
Member
jeffersonm began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jun 2017
Device: None
Quote:
Originally Posted by dunhill View Post
Have you tried the add book template as follows, to see if it works? ('P <Publicer>. +) - (? P <author> [^ _] +) - (? P <title>. +)
I do not think it is convenient for you to put the comments because they are infinite text fields. Try this waiting for a more accurate comment.
Thank you for the response! Unfortunately, I tried this and get the error "Invalid regular expression: unexpected end of pattern". I tried Publicer (above and Publisher. No difference.
jeffersonm is offline   Reply With Quote
Old 03-26-2020, 08:20 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 19,085
Karma: 32855143
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
There were some extra spaces in what @dunhill posted. And that first quote probably should have been a question mark. I think what he meant was:

Code:
(?P<publisher>.+?) - (?P<author>[^_]+?) - (?P<title>.+)
And the question mark after the plus is to make the matching non-greedy.

To get the comment as well:

Code:
(?P<publisher>.+?) - (?P<author>[^_]+?) - (?P<title>.+?) - (?P<comments>.+)
I haven't tested that in calibre. I did check it using https://regex101.com/.
davidfor is online now   Reply With Quote
Old 03-26-2020, 08:26 AM   #5
jeffersonm
Member
jeffersonm began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jun 2017
Device: None
Quote:
Originally Posted by davidfor View Post
There were some extra spaces in what @dunhill posted. And that first quote probably should have been a question mark. I think what he meant was:

Code:
(?P<publisher>.+?) - (?P<author>[^_]+?) - (?P<title>.+)
And the question mark after the plus is to make the matching non-greedy.

To get the comment as well:

Code:
(?P<publisher>.+?) - (?P<author>[^_]+?) - (?P<title>.+?) - (?P<comments>.+)
I haven't tested that in calibre. I did check it using https://regex101.com/.

That appears to work, thank you so much!! I appreciate everyone's help.
jeffersonm is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding books using Regular Expression! leomleite Calibre 2 11-02-2014 05:51 PM
Adding books, Regular expression help please Shadewing Library Management 13 04-04-2012 05:31 AM
Adding Books, regular expression smarties86 Calibre 4 12-19-2010 08:18 AM
Regular Expression on adding books. Lokro Calibre 4 11-06-2010 11:05 AM
Regular Expression For Adding Books jhart711 Calibre 3 09-27-2010 06:51 AM


All times are GMT -4. The time now is 02:34 PM.


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