Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 01-01-2026, 01:02 PM   #1
drawson1
Zealot
drawson1 began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Mar 2014
Device: Clara 2E, Clara BW, Samsung tablet
Using a prefix-rule for rating in catalog

I'm trying to set up a prefix rule ( --prefix-rules=() in 'calibredb catalog ....) for the rating field with no success. I've tried a couple of different options:

Code:
--prefix-rules="('Rating','rating','5','5')"
Code:
--prefix-rules="('Rating','rating',5,'5')"
which both return "string index out of range"

Code:
--prefix-rules="('Rating','rating',None,'0')"
which returns "object of type 'int' has no len()

Prefix rules I've set up for other fields work as expected based on the docs. Has anyone tried this?

Thanks!

dan
drawson1 is offline   Reply With Quote
Old 01-01-2026, 04:56 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 22,116
Karma: 30277960
Join Date: Mar 2012
Location: Sydney Australia
Device: none
In what format do you want the catalog ?

Quote:
Note that different catalog formats support different sets of options. To see the different options, specify the name of the output file and then the –help option.
See ==> calibredb catalog

BR
BetterRed is offline   Reply With Quote
Old 01-01-2026, 05:28 PM   #3
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 946
Karma: 1004846
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
I tested this command from the Linux Mint terminal: `calibredb list --search="rating:5" --with-library="/home/walter/Dropbox/Library Walter"`. This tells you which books have a rating of 5.

To generate the catalog, use: `calibredb list --search="rating:5" --with-library="/the path to your Calibre library"`
dunhill is offline   Reply With Quote
Old 01-02-2026, 06:40 AM   #4
Katja_hbg
Groupie
Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.Katja_hbg can program the VCR without an owner's manual.
 
Posts: 192
Karma: 197760
Join Date: Oct 2015
Device: Kobo Glo HD (landscape), Kobo Aura One
By whatever reason the field rating is not available in catalog for prefix or excluding. Anyhow for the most fields the value is yes/no and cannot be specified. Maybe the GUI catalog (menu icon book convert) make this more clear.

The workaround is to use an own customized field; one for each rating value. That should work.
Katja_hbg is offline   Reply With Quote
Old 01-02-2026, 07:30 AM   #5
drawson1
Zealot
drawson1 began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Mar 2014
Device: Clara 2E, Clara BW, Samsung tablet
Quote:
Originally Posted by BetterRed View Post
In what format do you want the catalog ?



See ==> calibredb catalog

BR
I'm generating an EPUB catalog
drawson1 is offline   Reply With Quote
Old 01-02-2026, 07:33 AM   #6
drawson1
Zealot
drawson1 began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Mar 2014
Device: Clara 2E, Clara BW, Samsung tablet
Quote:
Originally Posted by Katja_hbg View Post
By whatever reason the field rating is not available in catalog for prefix or excluding. Anyhow for the most fields the value is yes/no and cannot be specified. Maybe the GUI catalog (menu icon book convert) make this more clear.

The workaround is to use an own customized field; one for each rating value. That should work.
OK, thanks! ... I'll give the custom field a try.
drawson1 is offline   Reply With Quote
Old 01-03-2026, 02:10 PM   #7
drawson1
Zealot
drawson1 began at the beginning.
 
Posts: 100
Karma: 10
Join Date: Mar 2014
Device: Clara 2E, Clara BW, Samsung tablet
SOLVED.

The custom field is the key as follows:
  • Add a custom column. I used a text column, limited to the values 0 - 5 (I called it "ratingcalc")
  • Populate that column to match the rating. I'm on linux, so this was done with a 6-line shell script :-). One note - in my environment only "read" books have ratings, but not all read books have ratings. I only started adding the ratings a couple of years ago.
  • Use the new text column in a prefix rule. This was done in my catalog generation shell script, but it also works fine in the GUI:

Code:
--prefix-rules="(\
                         ('Rating','#ratingcalc','False',''),\
                         ('Rating','#ratingcalc','5','5'),\
                         ('Rating','#ratingcalc','4','4'),\
                         ('Rating','#ratingcalc','3','3'),\
                         ('Rating','#ratingcalc','2','2'),\
                         ('Rating','#ratingcalc','1','1'),\
                         ('Read books','#read','True','✓'),\
                         ('Not Kobo','#to_kobo','False','×')\
                         )"
  • Update the catalog script to also populate the new column for those books where the original rating field is populated.

The resulting EPUB catalog shows a check-mark as the prefix character for books that are "read" but have no rating, and a number for books that have a rating.

A few related notes:
  • I tried using a few other column types with no success:
    • Composite column based on the original ratings field ( using '{ratings:ratings_to_stars()}' )
    • Integer column
    • Ratings column
  • The scripts update this field using 'calibredb set_metadata'. If you pass a value outside the field limits (<0 or >5 in my example), set_metadata succeeds (ie, returns 0), but leaves the field value unchanged

:-))

HTH!

Dan

Last edited by drawson1; 01-03-2026 at 02:52 PM.
drawson1 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Copy and Round Custom #rating Column to Default Rating Stars Far_Pen_6884 Library Management 1 09-15-2025 08:32 AM
Catalog: prefix according to rating? Phssthpok Library Management 2 08-12-2022 07:00 AM
Catalog command-line syntax for prefix-rules drawson1 Library Management 1 03-24-2021 12:23 AM
Calibredb Catalog "cannot generate catalog in EPUB format rracoon01 Library Management 5 07-13-2018 09:19 PM
mobi catalog = periodical, ePub catalog = book trekchick Library Management 7 03-12-2011 02:11 PM


All times are GMT -4. The time now is 06:19 AM.


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