![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
Help needed: Regex for Add Books
This is my current regex:
Code:
^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s)?(?P<title>[^(]+)(?:\(.*\))? Code:
author - [series series-index] title Code:
author - [series series-index] !tag1, tag2# title |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
Do you want to capture everything between a "!" and a "#" as the contents for the tags column?
If so, try: Code:
^(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>[\d\.]+)(?:\s*\])?\s)?(?:\s*!(?P<tags>.+)#\s+)?(?P<title>[^(]+)(?:\(.*\))?
Last edited by eschwartz; 03-23-2015 at 08:04 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
Doesn't read the tags. Everything else still works.
|
![]() |
![]() |
![]() |
#4 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
calibre doesn't read into Tags column from filename.
EDIT: Setting "Read metadata from file rather than filename" does it. Last edited by macnab69; 03-24-2015 at 06:48 AM. |
![]() |
![]() |
![]() |
#5 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
That would imply the tags and other info are already embedded in the file.
Also, sorry for not realizing Add books doesn't allow tags as a filename metadata source. ![]() Last edited by eschwartz; 03-24-2015 at 12:23 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,730
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@macnab69 - the cli command calbredb -add can contain tags.
With a text editor perhaps you could munge the file names into calibredb add commands. BR |
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
@eschwartz: In my case the books have been through calibre to edit them, because so many have terrible layouts and formatting.
@Better Red: Some sort of script would be needed to parse each filename. At least calibredb add allows to to set Tags. |
![]() |
![]() |
![]() |
#8 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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)
|
If they have been through calibre, why do you need to add metadata based on the filename?
![]() |
![]() |
![]() |
![]() |
#9 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,730
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
@macnab - I would pipe a directory list of the 'files with tags in file names' into a command file -- bat, bash -- whatever.
I'd then open that file in an editor like Notepad++ or emacs, do find & replaces to transform each line into a calibredb add command with the --tags "blah, blah blah, blah blah blag" etc. Run the command file, throw it away BR |
![]() |
![]() |
![]() |
#10 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 129
Karma: 5754
Join Date: Jan 2012
Location: South Africa
Device: Kindle 4
|
@eschwartz - I fix the books for a friend who is not really savvy. It wasn't until now that I thought about the metadata being embedded in the file.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
More help needed: regex for add books | macnab69 | Library Management | 11 | 06-17-2013 12:15 PM |
Help: regex for add books | macnab69 | Library Management | 4 | 06-16-2013 01:53 AM |
My RegEx works in Test but not for Add Books | kanigetts | Library Management | 11 | 09-18-2012 02:59 AM |
Want RegEx to add books to Calibre | huon | Library Management | 0 | 02-02-2012 12:52 AM |
Add Books - Regex Help Please | nynaevelan | Calibre | 2 | 08-16-2011 01:30 PM |