How I manage documents if all of them in one flat folder using calibredb.el

You may not know: there is one type of metadata in Calibre, called folder metadata. It is also be used in elink device if you use calibre to transfer files to elink device. A hidden file named .metadata.calibre.

Unlike the original database metadata.db, metadata needs ebooks be resided inside a non-flat folder, while the .metadata.calibre is a json file, and it has all the metadata for all documents/ebooks under one flat folder.

Therefore, by parsing .metadata.calibre, we can manage all documents inside one flat folder using calibredb.el - The documents management software inside Emacs. What amazing thing is that, after generating the folder meatadata, calibredb.el can smartly filter metadata with live filter feature without using calibre or other calibre command lines, making it also be able to manage ebooks inside Android Emacs where it is unable to install calibre on Termux at this moment.

Install or update calibredb.el to the latest version.

Generate the folder metadata: .metadata.calibre

Launch calibre, Connect/Share, Connect to folder, then .metadata.calibre was generated in that folder, finally you can close calibre.

Config calibredb.el

There is only three things to configure, that is setup calibredb-root-dir to point to the document folder, calibredb-db-dir points to the .metadata.calibre. and calibredb-library-alist holds all libraries.

(setq calibredb-root-dir "/home/damonchan/Data/Books/")
(setq calibredb-db-dir (expand-file-name ".metadata.calibre" calibredb-root-dir))
(setq calibredb-library-alist `((,calibredb-root-dir)
                                  (,(pcase system-type
                                      ('gnu/linux
                                       (expand-file-name "Calibre" "~/Data/Ebooks/"))
                                      ('darwin
                                       (expand-file-name "Calibre" "~/Ebooks/"))))
                                  (,(expand-file-name "web_doc" org-directory))))

Run calibredb.el

1
M-x cabliredb

Do live search with /, enter to open the file, or press . to open dired.

Demo

Please notice that not all features designed for calibredb metadata database are usable. But search and open is working alright. If you need to add or delete file, you need to generate the .metadata.calibre using calibre again to refresh the metadata. Because calibredb.el is not able to generate .metadata.calibre at this moment.

Bonus Tip

I love flat folder, so that I can use paw.el to manage ebooks annotations across devices (android and desktop).

Enjoy

updatedupdated2025-02-152025-02-15