![]() |
#1 |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2018
Device: Lenovo Yoga Tab 3
|
Display smallest format's file size?
In Calibre, the "size" column displays the size of the largest format for any given book. I'd like to be able to create a custom column to display the size of the smallest format of any given book. Is this possible? If so, how should I go about it?
|
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use the formats_sizes() function. But note that doing this is very slow because it means filesystem access for evey format for every book.
|
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2018
Device: Lenovo Yoga Tab 3
|
Thanks, Kovid!
|
![]() |
![]() |
![]() |
#4 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Question, how do you use formats_sizes() in bulk s&r?
I've tried: {formats_sizes} {formats_sizes()} {id:formats_sizes()} {title:formats_sizes()} {self:formats_sizes()} {book:formats_sizes()} I get S/R TEMPLATE ERROR on all of them (either unknown field or too many arguments). |
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Instead you can use either template program mode Code:
{:'formats_sizes()'} Code:
program: formats_sizes() |
|
![]() |
![]() |
![]() |
#6 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Thanks!
This got me the raw data needed: Code:
{:'select(formats_sizes(),'EPUB')'} I have another question, if I wanted it displayed as #,### (in KB), can I store in a number-type custom column and use just the display format options to prettify? Or do I need to store the data first in an number-type custom column and then create another custom column (built from other columns) to get the prettified formatting? For speed, I'm guessing minimizing filesystem access is best so better to have a placeholder for file size rather than call formats_sizes() for each book in the library every time I open Calibre? Thanks again! |
![]() |
![]() |
![]() |
#7 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,048
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() That (and some others) field auto updates during the normal management of books. Use a Custom field for stable data ![]() |
|
![]() |
![]() |
![]() |
#8 | |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
e.g. #epub_size (int) - {:'select(formats_sizes(),'EPUB')'} set via bulk s&r then number formatting done via display formats option (is that doable?) or #epub_size (int) - {:'select(formats_sizes(),'EPUB')'} set via bulk s&r #size (composite) - {#epub_size:human_readable()} |
|
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
You can easily do it with two columns, one containing the value and the other a composite column (built from other columns) that formats the number as you wish, doing any arithmetic needed. The first column can be precomputed or also be a composite column that fetches the data on demand. You can do it in one composite column in general program mode, fetching the value then formatting it. You can do it in one composite column where the value to be formatted is precomputed and inserted into the template. How and when you fetch the number to insert into the template is up to you. I think there are two practical possibilities:
Finally, you can do it in one numeric custom column using the above methods, where the precompute cycle does the appropriate arithmetic so the format string will be able to display the number (probably divide by 1000). |
|
![]() |
![]() |
![]() |
#10 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 893
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
|
The formats_sizes function converts from mb to kb?
Or how would the syntax be for a custom column. |
![]() |
![]() |
![]() |
#11 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
For example, this template returns the size of the EPUB format in KB, or the empty string if there isn't an EPUB format. Code:
program: if epub_size = select(formats_sizes(), 'EPUB') then format_number(floor(divide(epub_size, 1024)), '{:,d} KB') fi Code:
program: human_readable(select(formats_sizes(), 'EPUB')) Last edited by chaley; 02-07-2021 at 09:51 AM. |
|
![]() |
![]() |
![]() |
#12 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 893
Karma: 810834
Join Date: Sep 2017
Location: Buenos Aires, Argentina
Device: moon+ reader, kindle paperwhite
|
Thanks for the tip and the example Chaley!
|
![]() |
![]() |
![]() |
#13 |
Member
![]() Posts: 11
Karma: 10
Join Date: Feb 2018
Device: Lenovo Yoga Tab 3
|
Would this kind of custom column still be very slow or have changes been made since 2018 that this would now be more feasible?
|
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,445
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
Tags |
custom columns, format size |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Best document format for reading with smallest file size. | rupeshforu3 | General Discussions | 21 | 12-10-2017 04:47 PM |
Refresh file size display after changing PDF outside calibre? | gingerbeardman | Library Management | 4 | 11-12-2017 05:28 AM |
Smallest text size | stethorn | Amazon Kindle | 1 | 10-12-2014 10:19 AM |
K3 Smallest Font Size Readability? | grownupboy | Amazon Kindle | 6 | 09-06-2010 08:19 PM |