![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 25748
Join Date: Apr 2011
Device: kindle
|
need helping link two template choices
Or at least that is what I think it is called.....
I want to write one line of code that chooses to which function or line of code to use based on if the book is a series or a stand along book based on a mass save to disk. The lines I want to combine with a either or type of code is the following: series/{series:sublist(0,1, ![]() ![]() ![]() or single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title} I think an if/then type of combination would work but everything I have tried has caused errors or the output is not where or how I want it to go. any help from those who know this coding better would be greatly appreciated. Thank Bulldogmo |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,511
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I am not sure what your first template is trying to do. It appears to be trying to extract the first character of the series, then the first 2 characters, then the third and fourth characters, then other stuff.
If the above is correct then this general progrm mode template does the job. Code:
program: if $series then template('series/{series:substr(0,1)}/{series:substr(0,2)}/{series:substr(2,4)}/{series_index:0>3s} - {title}/{author_sort:sublist(0,1,&)} - {series} - {series_index:0>3s} - {title}') else template('single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title}') fi |
![]() |
![]() |
![]() |
#3 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 25748
Join Date: Apr 2011
Device: kindle
|
Thank you I will try this....
|
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 25748
Join Date: Apr 2011
Device: kindle
|
Okay, what am I doing wrong?
program: if series_sort then template (series/{author_sort[0]}/{author_sort}/{series}/{series_index:0>3s} - {title}/{author_sort} - {series} - {series_index:0>3s} - {title}) else template ( single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title}) What I want to do is this: series/{author_sort[0]}/{author_sort}/{series}/{series_index:0>3s} - {title}/{author_sort} - {series} - {series_index:0>3s} - {title} The books will be saved to the hard drive in the directory series/author first Initial of last name, then by full name (last, first), it will then be saved by series title, then under that by series index, and book title. The formats will then be placed into that directory. If the book is NOT part of a series, it is to be saved with this: single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title} directory single books, first letter of last name, last name and then first name, title, and finally author last name, first, and title of book. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,511
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I suggest that you look at the General Program Mode template language documentation, and also use other templates as a pattern, such as the one I provided in a previous post.
The template you provided: Code:
program: if series_sort then template (series/{author_sort[0]}/{author_sort}/{series}/{series_index:0>3s} - {title}/{author_sort} - {series} - {series_index:0>3s} - {title}) else template ( single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title}) Here is a corrected version that runs. Code:
program: if $series then template('series/{author_sort[0]}/{author_sort}/{series}/{series_index:0>3s} - {title}/{author_sort} - {series} - {series_index:0>3s} - {title}') else template('single books/{author_sort[0]}/{author_sort:sublist(0,1,&)}/{title}/{author_sort} - {title}') fi |
![]() |
![]() |
![]() |
#6 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 65
Karma: 25748
Join Date: Apr 2011
Device: kindle
|
It works perfectly. Thank you. I am taking Python in the fall so hopefully, that will help me understand the language better.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Template: saving template tester when restarting Calibre | ownedbycats | Library Management | 14 | 03-29-2021 05:57 PM |
Template: Converting a search & replace into a template | ownedbycats | Library Management | 11 | 03-26-2021 04:32 AM |
Use column values to determine author link template? | eosrose | Calibre | 3 | 08-24-2013 12:34 AM |
I need Help With Default Author Link Template | BNGA | Library Management | 3 | 08-15-2013 11:40 PM |
Choices Choices - which reader do i buy | erithian | Which one should I buy? | 2 | 04-17-2009 10:53 AM |