M: find out for me quickly how to format integer columns in the utility program calibre to contain leading zeros.
G: [Non-text content: thoughts; content_type=thoughts]
G: [Non-text content: reasoning_recap; content_type=reasoning_recap]
G: Yes. In calibre’s template formatting, use:
0>3s
That means pad on the left with zeroes to a width of 3:
1 → 00112 → 012123 → 123So for a custom integer column such as #volume, the
template would be:
{#volume:0>3s}
One wrinkle: calibre normally renders an actual numeric
0 as blank. If you need zero itself to display as
000, use:
{#volume:0>3s:ifempty(0)}
This is explicitly documented by calibre as the method for displaying integer columns with leading zeroes. citeturn483245search12turn483245search0
M: and that's what i'd put into the "format for numbers" field in the custom column dialog?
G: [Non-text content: reasoning_recap; content_type=reasoning_recap]
G: Yes. In the custom column dialog’s “Format for numbers” field, put:
0>3s
That field expects just the format specifier, not the surrounding
{#column:...} template syntax.
M: Here's a broader concept that I'd like an answer about. I have taken to using the ability to add notes to various tags, etc., to entries in a catalog in that utility, which I'm not going to try and name because I'm using a vocal transcriber and it will spell it wrong. Anyway, for that catalog utility, one of the things that I appreciate about it is that a lot of the information that is included in the various entries goes into the subdirectory in a format that could conceivably be accessed by a script or program working in conjunction, or rather as kind of a wrapper to the utility, to add some functionality. But I have no idea how that utility stores the various notes, or if it can export them at all. Can you check on that and let me know what methods are used to store that information, and if there's a way to, like, export all of the notes I've entered about various authors into a single text file?
G: I’ll check how calibre stores notes attached to authors/tags/etc., and whether there’s a supported way to extract them in bulk rather than poking directly at the database.
G: [Non-text content: thoughts; content_type=thoughts]
G: [Non-text content: reasoning_recap; content_type=reasoning_recap]
G: Yes. I checked the current calibre documentation and source, and this is actually fairly friendly to the sort of wrapper/script idea you're describing.
The important distinction is that notes attached to authors,
tags, series, publishers, etc. are not stored alongside individual books
as ordinary metadata.opf data. Calibre has a
separate notes system. Current calibre source maintains the notes data
under a .calnotes area associated with the
library, while the normal book/category relationships and
identifiers live in the library's metadata.db. Calibre's
own library-export mechanism explicitly packages the notes separately as
notes.db, which confirms that they're treated as
library-level data rather than per-book files.
citeturn727147search0turn580539search2
More importantly, calibre provides an official database API
for reading them, so I would strongly prefer that over having a
script reverse-engineer .calnotes. The API includes:
get_all_items_that_have_notes(field_name) — tells you
which items have notes; if you don't specify a field, it can return them
grouped by field.get_item_name(field, item_id) — turns the internal ID
back into something useful like Isaac Asimov.notes_for(field, item_id) — retrieves the note
document.notes_data_for(field, item_id) — retrieves the fuller
note data.export_note(field, item_id) — exports one note as a
self-contained HTML document, including embedded images.
citeturn731243search3turn731243search0turn580539search0So yes, you absolutely could make a utility that dumps every
author note into one file. There doesn't appear to be a stock
calibredb export-all-author-notes-to-text command, but
calibre exposes essentially every operation needed to build one
cleanly.
For example, conceptually the result could be:
========================================
Isaac Asimov
========================================
Born 1920...
Primary SF period...
See also: Foundation chronology...
========================================
Ursula K. Le Guin
========================================
Earthsea...
Hainish material...
And the extraction logic is basically:
for author_id in db.get_all_items_that_have_notes('authors'):
author = db.get_item_name('authors', author_id)
note = db.notes_for('authors', author_id)
write(author, note)There is one wrinkle: the stored note is rich text/HTML rather than intrinsically plain text. Calibre supports formatting, links, images, etc. Its own API can export the complete note as HTML, and internally calibre also maintains searchable/plain textual content. citeturn580539search6turn580539search0 So a wrapper could reasonably generate any of:
author-notes.txt
author-notes.html
author-notes.md
or even one file per author.
That means this is actually better suited to what you're imagining than I initially expected. You do not need to scrape the GUI, and you shouldn't need to directly query undocumented SQLite tables. Calibre deliberately exposes notes through its Python database API. Its database API is intended for exactly this sort of programmatic access and can open a library by path. citeturn380783search4
One other potentially useful point for your larger wrapper idea: notes aren't restricted to authors. Calibre identifies them by field + item ID. Thus the same machinery can retrieve notes on:
authors
tags
series
publisher
#your_custom_category
provided that field supports notes. Calibre even has
field_supports_notes() to test that.
citeturn731243search3
So if you eventually wanted something like "generate a single human-readable reference document containing every note I've created anywhere in this library, organized by Authors / Tags / Series / whatever", that's quite feasible and could be done without modifying calibre itself.
If you want, I can next work out the actual small
Python/calibre-debug script that would dump all your author
notes into a single .txt or .html file. That
should be relatively short.