![]() |
#1 |
Enthusiast
![]() ![]() ![]() ![]() ![]() Posts: 47
Karma: 450
Join Date: Mar 2011
Device: PRS-600, PRS-650, Tolino Vision 3 HD, Kobo Libra H20
|
Book upload, Calibre Save Template sometimes parsed, sometimes not
Hello,
I've got a column defined (with some helper columns) and it displays nicely and correctly in the book detail view for all my books. I called that column "filenamekobo", because it's the filename I want to use on my kobo - surprise. I now set {#filenamekobo} as my save template in my device configuration. For many ebooks this works perfectly, books get the right name and path. But for some, it simply totally stops interpreting this column and the name it sends it to the device is #filenamekobo.epub (while still showing the correct value in the book detail view). This only happens for some ebooks and I haven't yet found out what the problem there is. One detail: It always works for the same books and not for others, but it doesn't change from time to time. I have not yet determined a difference between those where it works and where not - no special characters in title or series, for example. The whole thing starts with the column "serieswithoutthe": Code:
{series:re(The (.+),\g<1>)} Code:
{#serieswithoutthe[0]}-Series/{#serieswithoutthe}/{series_index:0>2s} - Code:
books/{series:test( {#seriesfolderkobo}, other/)}{title} Last edited by Irian; 06-16-2020 at 03:20 PM. |
![]() |
![]() |
![]() |
#2 |
Enthusiast
![]() ![]() ![]() ![]() ![]() Posts: 47
Karma: 450
Join Date: Mar 2011
Device: PRS-600, PRS-650, Tolino Vision 3 HD, Kobo Libra H20
|
Ok, I probably found the reason: The series was pretty old (I added the first books to my calibre probably more than 10 years ago).
When I renamed the series in all books of it, it worked. Then I renamed it back (to the one that produced the error) and suddenly it also works. My guess is that something has changed in the way Calibre handles/stores series data in the last years and older series have some property or whatever that confuses the save template. Additionally, just in case someone stumbles upon the templates, I was (rightly so) told that they are pretty messed up and the result is pretty unpredictable, so I switched to template program mode and did this, instead: Code:
program: stripped = re(field('series'), '^(A|The|An|Der|Die|Das)\s+', ''); initial = substr( stripped, 0, 1 ); index = template('{series_index:0>2s}'); foldernameforseries = strcat(initial, '-Series/', field('series'), '/', index, ' - '); defaultfoldername = 'other/'; finalfolder = test(field('series'), foldernameforseries, defaultfoldername); strcat('books/', finalfolder, field('title')); Last edited by Irian; 06-17-2020 at 06:46 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
FWIW: the line
Code:
index = template('{series_index:0>2s}'); Code:
idx = field('series_index'); index = contains(idx, '\.', format_number(idx, '05.2f'), format_number(idx, '02d')); If you want all series indices to be the same length, in the example's case 5 (nn.nn), then you could use Code:
format_number(field('series_index'), '05.2f') |
![]() |
![]() |
![]() |
#4 |
Enthusiast
![]() ![]() ![]() ![]() ![]() Posts: 47
Karma: 450
Join Date: Mar 2011
Device: PRS-600, PRS-650, Tolino Vision 3 HD, Kobo Libra H20
|
Thanks, I appreciate that. While the documentation for the template language is quite ok, do you know of any large collection of examples, because those tend to help a bit?
|
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The thread Plugboard, template, and custom composite column recipes has lots of examples.
The thread is a long slog, 59 pages, with much discussion about what templates should do. A lot of the early history discussion isn't correct anymore. If you want to read some recent discussion start at page 50 or so. |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple regexes in "save book to disk" template? | Phssthpok | Library Management | 1 | 07-12-2018 04:20 AM |
Save Template Help | Maverynthia | Library Management | 10 | 05-19-2014 12:37 PM |
Two XMLs cannot be parsed by Calibre | surf | Recipes | 13 | 02-10-2013 10:53 AM |
A little help with a save template...? | Belfaborac | Library Management | 2 | 02-04-2011 09:47 PM |
How should file names be parsed and prepared for calibre import? Use cases requested | GlennMaples | Calibre | 0 | 01-09-2011 12:41 AM |