Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-01-2024, 05:30 PM   #1
bulldogmo
Connoisseur
bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.
 
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,}/{series:sublist(0,2,}/{series:sublist(2,4,}/{series_index:0>3s} - {title}/{author_sort:sublist(0,1,&)} - {series} - {series_index:0>3s} - {title}

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
bulldogmo is offline   Reply With Quote
Old 01-01-2024, 06:01 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
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
chaley is offline   Reply With Quote
Old 01-01-2024, 08:59 PM   #3
bulldogmo
Connoisseur
bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.
 
Posts: 65
Karma: 25748
Join Date: Apr 2011
Device: kindle
Thank you I will try this....
bulldogmo is offline   Reply With Quote
Old 01-01-2024, 10:00 PM   #4
bulldogmo
Connoisseur
bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.
 
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.
bulldogmo is offline   Reply With Quote
Old 01-02-2024, 10:38 AM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
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})
is not sytactically correct. It is missing many quotes that delimit strings and is missing the final "fi" of the if-then-else statement. I also don't know why you are using "if series_sort". I suspect you mean "if series_sort()", but that does the same thing as "if $series" but more slowly.

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
chaley is offline   Reply With Quote
Old 01-02-2024, 01:30 PM   #6
bulldogmo
Connoisseur
bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.bulldogmo knows what's going on.
 
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.
bulldogmo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 08:33 PM.


MobileRead.com is a privately owned, operated and funded community.