![]() |
#1 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Mar 2019
Device: Onyx Boox
|
![]()
Hi, how do I add multiple rules for the Adding books - Reading metadata section of the settings? Seems to have only one line for one regular expression, but I need it to be able to guess from different filename formats.
|
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,463
Karma: 10684861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
How do you want the Calibre to decide which RE to use? Here is what you can do: Examine the filenames. Use file manager to separate the files into various groups according to filenames. Or write a script using Linux "find" command or whatever. Download plugin "Quick preferences" by Grant Drake for Calibre. Here you can define multiple Regular expressions and then select the one to use for the next file that you drag and drop (or import) into Calibre. BEWARE. Since the plugin was first developed something happened in Calibre code, so the first book you drag and drop in uses the previous RE. But, I haven't used it in quite some time. Define various REs for various book formats in the plugin options. You can then select various import options for next file from the menu. A few examples: Code:
Title - Author (Default) (?P<title>.+) - (?P<author>[^_]+) Author [- Series #]- Title ^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Series # - Author - Title ^(?P<series>((?!\s-\s).)+)\s(?P<series_index>[\d\.]+)\s-\s(?:(?:\[\s*)?(?P<author>.+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Author [(- Series #)]- Title ^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:[[(]\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*[])])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Author Name - Book title Author Name - Series name 2 - Book title You have also option to swap author names in the quick preferences plugin (firstname lastname vs lastname, firstname) Those REs *do* work I realize they might appear unreadable. I wrote and / or heavily modified those a few years ago and now they look as a bunch of scattered characters to me on the first glance. You have to take them apart piece by piece to understand them. Regular Expression language is quite dense and some people jokingly describe it as "Write Only". Calibre uses Python flavour of RE language I found book "Mastering Regular Expression" very enlightening when I was learning Regular Expressions (in the distant past). I am not sure it covers "Python flavour" of RE languages. There are a few threads here about Calibre RE specifics on Mobileread. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,721
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@kellykline - I normalise the filenames with external tools to a single simple regex-able pattern before I add them. Also, editing metadata in the booklist makes filling in the blanks eeasy - IMO. FX: copy/paste metadata from an existing book to one or more new books.
I use the same external tools to normalise other file names to consistent patterns, e.g. audio (music) files etc. BR Last edited by BetterRed; 02-23-2020 at 05:12 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Bulk metadata edit dialog: Use of regular expressions - how to? | DeepSeaDiver | Library Management | 8 | 07-14-2014 08:27 AM |
Multiple Field Regular Expressions | TheDauthi | Library Management | 2 | 09-14-2012 03:21 AM |
Regular Expression - Adding metadata from filename | LMF | Calibre | 1 | 03-20-2012 06:46 PM |
Metadata from filename (regular expressions) | geronimo72 | Library Management | 2 | 03-05-2012 04:14 PM |
Regular expressions - Single back-reference, multiple instances? | David Kudler | Sigil | 10 | 12-17-2011 12:05 PM |