This calibre python script might help. It produces a tab-separated CSV file for each book id provided on the command line. The CSV file contains 4 columns:
- book id
- extension
- size in bytes
- full path to file
To use it, save this script somewhere convenient:
Spoiler:
Code:
import json, os
from calibre.db.legacy import LibraryDatabase
'''
argument 1: path to the library
argument 2: list of book ids, e.g., 208,209. Quote the argument if there
are spaces between the ids. calibredb search can be used to
produce a list of ids. For example,
calibredb search "size:>100000"
finds all books with size > 100,000, printing the list of ids
output: a tab-separated csv list written to standard output
'''
# open the library database
db = LibraryDatabase(sys.argv[1]).new_api
# convert the book ids to a list of integers
book_ids = [int(bid.strip()) for bid in sys.argv[2].split(',')]
# get the library path from calibre. This removes symlinks and the like
library_path = db.backend.library_path
# print the header for the CSV output
print('\t'.join(('book_id', 'extension','size', 'path')))
# loop over the books generating the output for each format
for book_id in book_ids:
# get the list of formats for the book
formats = db.formats(book_id)
# loop over the formats, generating the csv line
for ext in formats:
# get the metadata for the format: the extension, size, path, and modtime
fmt_data = db.format_metadata(book_id, ext)
# write the csv line for the format
print('\t'.join((str(book_id), ext, str(fmt_data['size']), fmt_data['path'])))
Execute the script with
Code:
calibre-debug -e script_file_path library_path id1,id2,id3 > output.csv
Example using one of my test libraries:
- I saved the script as formats_sizes.py
- I used calibredb to get a list of ids, in this case books with 163 in the title
Code:
calibredb search "title:163"
that produced the output
Code:
1337,1343,1361,1434
You might want to use something like
Code:
calibredb search "size:>100000"
- I ran the script using
Code:
calibre-debug -e formats_sizes.py C:\CBH_Data\calibre.git\Library.test_small 1337,1343,1361,1434 > aaaaa.csv
The output is
Libre office calc shows this file as
Edit: it would be easy for the script to use a search expression instead of a list of ids. Let me know if you want an example script.