View Single Post
Old 04-02-2022, 12:33 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,455
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
It isn't quite clear what you want but I think this is it. This template requires the latest version of calibre (5.40).
Code:
program:
# Isolate the first genre. If there is never more than one then use
#	g = re($#genre, '\.', '/');
	g = re(sublist($#genre, 0, 1, ','), '\.', '/');
	
# Test if the genre starts with 'fiction'.
	if "^fiction" in g then
		g & '/' & $authors & '/' & test($series, $series & '/', '') & $title & ' - ' & $authors

	else
		g & '/' & test($series, $series & '/', '') & $title & ' - ' & $authors
	fi
EDIT: Rereading your post it might be that you want to check for a prefix of "fiction.", not "fiction". If so then change the "if "^fiction" line to be
Code:
	if "^fiction/" in g then
NB: Use a slash because periods have already been converted to slashes, and the anchor '^' causes the check to be "starts with".

Last edited by chaley; 04-02-2022 at 04:05 PM. Reason: small change to program comments
chaley is offline   Reply With Quote