02-06-2013, 04:15 PM | #1 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Save Template with dependent variable
I have books from both Amazon and other sources, and I keep them all in calibre. I would like to save them normally if they aren't from Amazon, but if they are, then save them according to the filename they were given by Amazon
(so they match the .sdr folder, with real pagenumbers and highlights). How do I set the save template so it uses {author_sort}/{title} - {authors} as usual, ONLY IF the custom field {#file} is empty? If it's filled in, the template should be that instead. Last edited by eschwartz; 03-04-2013 at 08:15 PM. |
02-06-2013, 04:49 PM | #2 |
Grand Sorcerer
Posts: 11,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Something like the following in general program mode should do the job, assuming that #file contains the exact filename.
Code:
program: ifempty(field('#file'), template('{author_sort}/{title} - {authors}')) Code:
{#file:'ifempty($, template('{author_sort}/{title} - {authors}'))'} |
02-06-2013, 05:39 PM | #3 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
It worked perfectly -- except for one thing; since I have titles with apostrophes, I got a template error. For instance, The Ultimate Hitchhiker's Guide to the Galaxy.
Code:
EXCEPTION: Formatter: failed to scan program. Invalid input - Douglas Adams')) near ( Code:
{#file:'ifempty($, template("{author_sort}/{title} - {authors}"))'} Now it shows Code:
Adams, Douglas/The Hitchhiker's Guide to the Galaxy - Douglas Adams Thanks!! Last edited by eschwartz; 03-04-2013 at 09:51 PM. |
02-06-2013, 05:44 PM | #4 |
Grand Sorcerer
Posts: 11,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Using the general program mode version avoids that sort of problem. You might want to consider it in case a title ever contains quotes (").
|
02-06-2013, 05:50 PM | #5 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Yeah, that worked too.
Last edited by eschwartz; 03-04-2013 at 09:51 PM. |
02-07-2013, 04:13 AM | #6 |
Grand Sorcerer
Posts: 11,691
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Just to be complete ...
Using the special bracket ([[ and ]] instead of { and }) specifier avoids the embedded quote and apostrophe problem in template program mode
Code:
{#file:'ifempty($, template('[[author_sort]]/[[title]] - [[authors]]'))'} |
02-17-2013, 07:01 PM | #7 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
For some reason this template works perfectly to show what the result will be in a custom field -- no matter what form I use -- but when I try to transfer a book over, it always ignores the template I entered under Preferences --> send books to device.
HELP!!! Last edited by eschwartz; 03-04-2013 at 09:51 PM. |
02-17-2013, 07:30 PM | #8 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Never mind. I found another thread that explained this problem -- https://www.mobileread.com/forums/sho...d.php?t=159523
For some reason the send books to device template still insists there is no such thing as any of my custom fields, but hey, it works anyway, I'm happy. I've decided to set the save template for the device and leave the generic save for other devices. Last edited by eschwartz; 03-04-2013 at 11:18 PM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Troubleshooting a Save Template. | Illyrie | Library Management | 5 | 02-08-2014 11:12 AM |
Need help on a Save to Disk template | fidvo | Library Management | 2 | 08-12-2012 03:34 PM |
A little help with a save template...? | Belfaborac | Library Management | 2 | 02-04-2011 09:47 PM |
Library name as calibre template variable | mdb5972 | Calibre | 6 | 01-15-2011 03:09 PM |
save to disk template | speakingtohe | Calibre | 9 | 05-29-2010 06:02 AM |