this post was submitted on 04 Jan 2024
5 points (100.0% liked)

Calibre

444 readers
1 users here now

For discussion about the Calibre ebook management software.

founded 1 year ago
MODERATORS
 

I use the page count plugin plus a template program I adapted from one found online (included below) to build a column that categorizes books by length. (I use this to build collections I use when I’m picking my next to read)

I’d like to exclude certain books from getting a classification though if they are PDFs or have tags like “Graphic Novel” or “Cookbook”. I’d appreciate any help figuring this out.

program:
val = field('#pagecount');
first_non_empty(
	cmp(val, 0, ' ', '', ''),
	cmp(val, 15, 'Flash Fiction', '', ''),
	cmp(val, 50, 'Short Story', '', ''),
	cmp(val, 100, 'Novelette', '', ''),
	cmp(val, 250, 'Novella', '', ''),
	cmp(val, 500, 'Short Novel', '', ''),
	cmp(val, 750, 'Long Novel', '', ''),	
	cmp(val, 1000, 'Tome', '', ''),
	'Toe Breaker');
top 1 comments
sorted by: hot top controversial new old
[–] JaymesRS 1 points 9 months ago* (last edited 9 months ago)

After working with the user chaley in MobileRead forums a while back, this is what they helped come up with and it works perfectly for my needs. Sorry for the delay in posting this, I just realized I should include this here for posterity. I just realized that the code block mixes up the formatting, don’t hesitate with any questions.

program: val = $#pagecount; if $formats && $formats != 'PDF' && list_intersection($tags, 'Graphic Novel, Cookbook', ',') == '' then switch_if( val ==# 0, '', val <# 15, 'Flash Fiction', val <# 50, 'Short Story', val <# 100, 'Novelette', val <# 250, 'Novella', val <# 500, 'Short Novel', val <# 750, 'Long Novel', val <# 1000, 'Tome', 'Toe Breaker') fi