calibredb
calibredb is the command line interface to the Calibre database.[1]
NOTE:
Documentation
- man 1 'calibredb' [EN]
Syntax
calibredb SUBCOMMAND [PARAMETER ...]
Subcommands & Parameters
- add
- Add the specified files as books to the database.
- -a AUTHORS, --authors AUTHORS
- Set the AUTHORS of the added book(s).
- -c PATH, --cover PATH
- PATH to the cover to use for the added book.
- -d, --duplicates,
- Add books to database even if they already exist. Comparison is done based on book titles.
- -l LANGUAGES, --languages LANGUAGES
- A comma separated list of LANGUAGES.
- -t TITLE, --title TITLE
- Set the TITLE of the added book(s)
- -T TAGS, --tags TAGS
- Set the TAGS of the added book(s).
- add (Additional parameters for directories)
- You can also specify directories.
- -1, --one-book-per-directory
- Assume that each directory has only a single logical book and that all files in it are different e-book formats of that book.
- -r, --recurse
- Process directories recursively.
- export
- Export the books specified by ids (a comma separated list) to the filesystem.
- --dont-save-cover
- Normally, Calibre will save the cover in a separate file along with the actual e-book files. Specifying this switch will turn this behavior off.
- --dont-save-extra-files
- Save any data files associated with the book when saving the book. Specifying this switch will turn this behavior off.
- --dont-update-metadata
- Normally, Calibre will update the metadata in the saved files from what is in the Calibre library. Makes saving to disk slower. Specifying this switch will turn this behavior off.
- --dont-write-opf
- Normally, Calibre will write the metadata into a separate OPF file along with the actual e-book files. Specifying this switch will turn this behavior off.
- --formats LIST
- Comma separated LIST of formats to save for each book. By default all available formats are saved.
- --replace-whitespace
- Replace whitespace with underscores.
- --single-dir
- Export all books into a single folder
- --template TEMPLATE
- The TEMPLATE to control the filename and folder structure of the saved files. Default is {author_sort}/{title}/{title} - {authors} which will save books into a per-author subfolder with filenames containing title and author.
- Available controls are: author_sort, authors, id, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, tags, timestamp, title.
- --to-dir
- Export books to the specified folder. Default is .
- --to-lowercase
- Convert paths to lowercase.
- list
- List the books available in the Calibre database.
- --ascending
- Sort results in ascending order.
- -f FIELDS, --fields FIELDS
- The FIELDS to display when listing books in the database. Should be a comma separated list of fields.
- Available fields: author_sort, authors, comments, cover, formats, id, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, timestamp, title, uuid. Default: title,authors. The special field all can be used to select all fields.
- --for-machine
- Generate output in JSON format, which is more suitable for machine parsing. Causes the line width and separator options to be ignored.
- -s QUERY, --search QUERY
- Filter the results by the search QUERY. For the format of the search query, please see the search related documentation in the User Manual.
- --separator
- The string used to separate fields. Default is a space.
- --sort-by FIELDS
- The FIELDS by which to sort the results.
- Available fields: author_sort, authors, comments, cover, formats, id, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, timestamp, title, uuid. Default: id.
Examples
- Export ebooks by command line
calibredb list --ascending --fields 'id' --for-machine \
--search 'tags:"=Manual" and tags:"=Diving"' \
--sort-by 'author_sort,title' \
| jq --raw-output '. | map(.id) | join(",")' \
| xargs calibredb export --dont-save-cover --dont-save-extra-files \
--dont-update-metadata --dont-write-opf --formats 'pdf' --single-dir \
--template '{authors} - {title}' --to-dir="${HOME}/tmp"
- Import an ebook by command line
calibre --shutdown-running-calibre
calibredb add --one-book-per-directory '.'
References
- ↑ Project contributors. "calibredb." Calibre project. https://manual.calibre-ebook.com/generated/en/calibredb.html (accessed 18.08.2025)