View Single Post
Old 03-09-2021, 05:21 AM   #3
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,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by jbacelar View Post
This is the template I use in the custom column for Kbytes:

program:
a=divide(booksize(), 1024);
a=re(a,'(\d+)\.\d+','\1');
a=add(a,1);
format_number(a,'n');


And so I have exactly the same value that the file shows in Windows.
Just FYI:

Starting in calibre 4.23 you can write:
Code:
program:
	format_number(add(floor(divide(booksize(), 1024)), 1), 'n')
The 'floor()' function was added in that release.

Starting in the next calibre release (5.13) you can write:
Code:
program:
	format_number(floor(booksize()/1024)+1,'n')
The arithmetic operators will be added in that release.
chaley is offline   Reply With Quote