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-24-2024, 12:35 PM   #1
oloco
Junior Member
oloco began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jun 2024
Device: kindle
looking for the correct regex

Hi,
During the last years, I've been storing all my books using this simple format:

El tutorial de python - Guido van rossum (2017).pdf
Zed A. Shaw - Learn Python The Hard Way (2011).epub

I'm lookinf for a regex template to be able to capture the metadata correctly.

I've tried multiple kind of combinations, but I'm not being able to capture the year.

One of the last examples I tried:

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

No matter the way I trie.. i never get the year.

Could yopu please help me with this?

Thanks in advance!
oloco is offline   Reply With Quote
Old 07-09-2024, 08:30 AM   #2
oloco
Junior Member
oloco began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jun 2024
Device: kindle
Anyone?
Just some help, please
oloco is offline   Reply With Quote
Advert
Old 07-13-2024, 04:52 PM   #3
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
You forgot the parentheses:
Code:
(?P<author>[^_-]+) - (?P<title>[^_].+) \((?P<published>.+)\)
Divingduck is offline   Reply With Quote
Old 07-15-2024, 10:31 AM   #4
oloco
Junior Member
oloco began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jun 2024
Device: kindle
Quote:
Originally Posted by Divingduck View Post
You forgot the parentheses:
Code:
(?P<author>[^_-]+) - (?P<title>[^_].+) \((?P<published>.+)\)
Hi Divingduck,

thanks a lot for your answer. I've just tried the example you propposed, but it doesn't seem to work. The problem is that the year is not being detected.

Do you have any other seugestion for me?

Thanks a lot!!
oloco is offline   Reply With Quote
Old 07-16-2024, 10:25 AM   #5
Divingduck
Wizard
Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.Divingduck ought to be getting tired of karma fortunes by now.
 
Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
Hm,
See attached pictures. Looks good for me.
I attached two dummy files w/o content that I used as test. In the first two pictures I made a test with the import test dialog. You may recognize that you provide two different examples, one with [author - title (year).ext] and the other with [title - author (year).ext]. In this case you need two separate templates for matching the metadata sequence and then switch to the one needed for importing.

For my example I use [author - title (year).ext] with:
Code:
(?P<author>[^_-]+) - (?P<title>[^_].+) \((?P<published>.+)\)
((?P<title>[^_].+) - ?P<author>[^_-]+) \((?P<published>.+)\)

Variations for [author - title (year).ext]:
Code:
(?P<author>[^_-]+) - (?P<title>[^_].+) \((?P<published>[0-9]{4})\)
or
Code:
(?P<author>[^_-]+) - (?P<title>[^_].+) \((?P<published>\d{4})\)
Picture 3 shows the imported files with the correct author, Title and publish year. Be aware you need to uncheck the box for [Read metadata from file contents rather than file name] for reading the meta data from file name, see picture 4

Template for [title - author (year).ext] should be:
Code:
((?P<title>[^_].+) - ?P<author>[^_-]+) \((?P<published>.+)\)
Attached Thumbnails
Click image for larger version

Name:	calibre_MetadataFromFilename1.PNG
Views:	43
Size:	54.5 KB
ID:	209591   Click image for larger version

Name:	calibre_MetadataFromFilename2.PNG
Views:	40
Size:	61.7 KB
ID:	209592   Click image for larger version

Name:	calibre_MetadataFromFilename3.PNG
Views:	35
Size:	194.8 KB
ID:	209593   Click image for larger version

Name:	calibre_MetadataFromFilename4.PNG
Views:	31
Size:	13.0 KB
ID:	209594  
Attached Files
File Type: pdf El tutorial de python - Guido van rossum (2017).pdf (31.2 KB, 31 views)
File Type: epub Learn Python The Hard Way - Zed A. Shaw (2011).epub (1.8 KB, 25 views)
Divingduck is offline   Reply With Quote
Advert
Old 07-16-2024, 10:42 AM   #6
Yves54
Junior Member
Yves54 began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Apr 2015
Device: kobo glo
Hey! You can try this regex to capture the year:
(?P<title>.+?) - (?P<author>[^-]+?) \((?P<year>\d{4})\)\.
Yves54 is offline   Reply With Quote
Old 07-16-2024, 11:30 AM   #7
oloco
Junior Member
oloco began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jun 2024
Device: kindle
Wink SOLVED - looking for the correct regex

Hi @Divingduck and Yves54.

I'be just tested " (?P<title>[^_-]+) - (?P<author>[^_].+) \((?P<published>.+)\) " and seems to work fine for me.

Thanks a lot for your help!!!
oloco is offline   Reply With Quote
Reply

Tags
calibre, metadata, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex in Regex function mode lindlind Editor 5 03-22-2024 04:41 AM
pdf regex question - regex that wraps to a new line flyash Conversion 1 09-05-2021 10:00 AM
Predefined regex for Regex-function sherman Editor 3 01-19-2020 06:32 AM
RegEx to correct Single quote to Double? phossler Editor 3 02-22-2015 02:48 PM
Is this e-pub correct? silviolorusso ePub 12 06-08-2011 04:52 PM


All times are GMT -4. The time now is 07:59 AM.


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