![]() |
#1 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Saving ebooks Template Problem
Hi.
Could it be possible to use composite columns in the template for saving to disk? I have the following template but it reverts back to the one before when I try to use it: Code:
'{#fandom_main} - {#fandom_secondary}/{author}/{title} ({#story_id}) Otherwise some of the names of folders it saves to ends up being longer than my windows can handle like the following: Quote:
Edit: After further thought, could I create a template where only part of it is activated based on conditions like amount of tags in a custom tag-column? Last edited by Tanjamuse; 09-16-2018 at 05:34 AM. |
|
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
You can use composite columns. You can use the function sublist e.g.
{tags:sublist(0,2,\,)} to extract values from a list like tags. https://manual.calibre-ebook.com/gen...ndex-separator Last edited by Divingduck; 09-16-2018 at 06:01 AM. |
![]() |
![]() |
![]() |
#3 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
@Kovid,
I think, there seems to be something wrong in the manual. Missing/wrong character for backslash. First place: https://manual.calibre-ebook.com/template_lang.html, section: "Using functions in templates - single-function mode" Quote:
Second place: https://manual.calibre-ebook.com/gen...ndex-separator Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
For the template
{#fandom_main} - {#fandom_secondary}/{author}/{title} ({#story_id}) change to: {#fandom_main:sublist(0,2,\,)} - {#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id}) In case your column definition is like tags. If not, you need to check if your list separator is a comma or something else and correct the separator to what ever you are using. The result should be something like fandom_main1,fandom_main2 - fandom_secondary,fandom_secondary\author\title (story_id) It takes from each of your two fandom columns list the first two items. |
![]() |
![]() |
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
The separator is a &.
Alternate I have a composite column like this: Code:
{#fandoms:count(&)} if it's more than 2 fandoms add Multi-Crossovers to the folder it saves to? |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
What is your column definition exactly for both columns (with an example)?
Is it only a text column like Buffy the Vampire Slayer,Cheers (TV)&Cupid (TV 1998)&Star Trek_ Deep Space Nine Ties Then your separator should be & or \& In the end you can do do everything you want in a template. If you want to do more complex combinations use the program mode in the template, e.g. Spoiler:
For now I haven't the time to help more but this evening I can spend some time to help if you give me some more input of your structure (or maybe someone else can jump in too). ![]() |
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
Ok, I'll try:
I've added screenshots for all the columns involved. I think I would prefer this solution: If the count of fandoms is more than 2, have the template put the story in a folder called: Multiple Crossovers without adding the fandoms. The rest of it would be like the one I have (it will always end with this): Code:
/{author}/{title} ({#story_id}) |
![]() |
![]() |
![]() |
#9 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,144
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
https://github.com/kovidgoyal/calibr...af0b50ad768902
should take care of it when the manual is rebuilt for the next release. |
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
I've looked over the template language in the manual and found this thread: https://www.mobileread.com/forums/sh...d.php?t=294354
Which got me to here: Code:
{#fandoms:sublist(0,1,&)||/}{#fandoms:sublist(0,2,&)||/}/{author}/{title} ({#story_id}) The template above gives me this: Code:
Buffy the Vampire Slayer,Cheers (gy,A-Team (TV),I Dream of Jeannie |
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
|
![]() |
![]() |
![]() |
#12 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
Quote:
Quote:
Code:
program: tmp1 = template('{#fandom_main:sublist(0,2,\,)} - {#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp2 = template('Multiple Crossovers/{author}/{title} ({#story_id})'); cmp( count( field('#fandom_main'), ','), 2, tmp1, tmp2, tmp2) Reference: https://manual.calibre-ebook.com/gen...p-x-y-lt-eq-gt https://manual.calibre-ebook.com/tem...l-program-mode Last edited by Divingduck; 09-17-2018 at 04:46 AM. |
||
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
I've made a small change to what you posted since it had to be 3 fandoms or more instead of 2, I've also deleted the - because it added it to the end of the folder names whenever there was only 1 or 2 fandoms
![]() Code:
program: tmp1 = template('{#fandom_main:sublist(0,2,\,)}{#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp2 = template('Multiple Crossovers/{author}/{title} ({#story_id})'); cmp( count( field('#fandom_main'), ','), 3, tmp1, tmp2, tmp2) |
![]() |
![]() |
![]() |
#14 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
Not sure if I get your request correct. a example could help for each variant
![]() When you need more differentiation than less, equal, greater then the function switch() is maybe more suitable for your task. Something like: Code:
program: tmp0 = template('No Crossovers/{author}/{title} ({#story_id})'); tmp1 = template('{#fandom_main:sublist(0,2,\,)}{#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp2 = template('Crossovers/{#fandom_main:sublist(0,2,\,)}{#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp3 = template('Multiple Crossovers/{author}/{title} ({#story_id})'); ## old version check if count is lt, eq,gr # cmp( # count( # field('#fandom_main'), # ','), # 3, # tmp1, # tmp2, # tmp2); ## new version as "case of count =x" switch( count(field('#fandom_main'), ','), 0, tmp0, 1, tmp1, 2, tmp2, 3, tmp3, tmp3); Regarding the '-', you can use as well |-|, || or |-|- for a prefix and/or suffix |
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
|
I'll try to be more specific:
I would like them sorted like this: 3 or more fandoms in Multiple Crossovers only 2 fandoms in Crossovers The one below only creates the Crossover and no longer the Multiple Crossovers, instead it creates a folder with only the first 2 fandoms in the long list from the multiple crossovers. Code:
program: tmp0 = template('No Crossovers/{author}/{title} ({#story_id})'); tmp1 = template('{#fandom_main:sublist(0,2,\,)}{#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp2 = template('Crossovers/{#fandom_main:sublist(0,2,\,)}{#fandom_secondary:sublist(0,2,\,)}/{author}/{title} ({#story_id})'); tmp3 = template('Multiple Crossovers/{author}/{title} ({#story_id})'); ## old version check if count is lt, eq,gr # cmp( # count( # field('#fandom_main'), # ','), # 3, # tmp1, # tmp2, # tmp2); ## new version as "case of count =x" switch( count(field('#fandom_main'), ','), 0, tmp0, 1, tmp1, 2, tmp2, 3, tmp3, tmp3); Last edited by Tanjamuse; 09-17-2018 at 02:43 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Saving ebooks problems | Tanjamuse | Calibre | 12 | 07-15-2018 08:37 PM |
Help with a 'Saving Books to Disk' Template | Vortex | Calibre | 5 | 12-04-2014 09:18 AM |
help with saving template having multiple authors? | miquele | Library Management | 2 | 04-16-2013 04:49 PM |
Save template problem | antoon | Library Management | 12 | 08-17-2012 12:47 PM |
Saving to Disk Template | hurricane51 | Conversion | 2 | 07-07-2011 01:22 AM |