calibredb

calibredb command [options] [arguments]

calibredb is the command line interface to the calibre database. It has several sub-commands, documented below:

Global options

--library-path
Path to the calibre library. Default is to use the path stored in the settings.

list

calibredb list [options]

List the books available in the calibre database.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--ascending
Sort results in ascending order
--fields, -f
The fields to display when listing books in the database. Should be a comma separated list of fields. Available fields: publisher,series_index,formats,isbn,uuid,pubdate,rating,series,timestamp,author_sort,cover,comments,authors,title,tags,size Default: title,authors. The special field “all” can be used to select all fields. Only has effect in the text output format.
--help, -h
show this help message and exit
--line-width, -w
The maximum width of a single line in the output. Defaults to detecting screen size.
--output-format
The format in which to output the data. Available choices: [‘text’, ‘xml’, ‘stanza’]. Defaults is text.
--prefix
The prefix for all file paths. Default is the absolute path to the library folder.
Filter the results by the search query. For the format of the search query, please see the search related documentation in the User Manual. Default is to do no filtering.
--separator
The string used to separate fields. Default is a space.
--sort-by
The field by which to sort the results. Available fields: publisher,series_index,formats,isbn,uuid,pubdate,rating,series,timestamp,author_sort,cover,comments,authors,title,tags,size Default: None
--version
show program’s version number and exit

add

calibredb add [options] file1 file2 file3 ...

Add the specified files as books to the database. You can also specify directories, see the directory related options below.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--duplicates, -d
Add books to database even if they already exist. Comparison is done based on book titles.
--help, -h
show this help message and exit
--one-book-per-directory, -1
Assume that each directory has only a single logical book and that all files in it are different e-book formats of that book
--recurse, -r
Process directories recursively
--version
show program’s version number and exit

remove

calibredb remove ids

Remove the books identified by ids from the database. ids should be a comma separated list of id numbers (you can get id numbers by using the list command). For example, 23,34,57-85

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--help, -h
show this help message and exit
--version
show program’s version number and exit

add_format

calibredb add_format [options] id ebook_file

Add the ebook in ebook_file to the available formats for the logical book identified by id. You can get id by using the list command. If the format already exists, it is replaced.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--help, -h
show this help message and exit
--version
show program’s version number and exit

remove_format

calibredb remove_format [options] id fmt

Remove the format fmt from the logical book identified by id. You can get id by using the list command. fmt should be a file extension like LRF or TXT or EPUB. If the logical book does not have fmt available, do nothing.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--help, -h
show this help message and exit
--version
show program’s version number and exit

show_metadata

calibredb show_metadata [options] id

Show the metadata stored in the calibre database for the book identified by id. id is an id number from the list command.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--as-opf
Print metadata in OPF form (XML)
--help, -h
show this help message and exit
--version
show program’s version number and exit

set_metadata

calibredb set_metadata [options] id /path/to/metadata.opf

Set the metadata stored in the calibre database for the book identified by id from the OPF file metadata.opf. id is an id number from the list command. You can get a quick feel for the OPF format by using the –as-opf switch to the show_metadata command.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--help, -h
show this help message and exit
--version
show program’s version number and exit

export

calibredb export [options] ids

Export the books specified by ids (a comma separated list) to the filesystem. The export operation saves all formats of the book, its cover and metadata (in an opf file). You can get id numbers from the list command.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--all
Export all books in database, ignoring the list of ids.
--dont-asciiize
Normally, calibre will convert all non English characters into English equivalents for the file names. WARNING: If you turn this off, you may experience errors when saving, depending on how well the filesystem you are saving to supports unicode. Specifying this switch will turn this behavior off.
--dont-save-cover
Normally, calibre will save the cover in a separate file along with the actual e-book file(s). 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
Comma separated list of formats to save for each book. By default all available books are saved.
--help, -h
show this help message and exit
--replace-whitespace
Replace whitespace with underscores.
--single-dir
Export all books into a single directory
--template
The template to control the filename and directory structure of the saved files. Default is “{author_sort}/{title}/{title} - {authors}” which will save books into a per-author subdirectory with filenames containing title and author. Available controls are: {rating, series_index, isbn, pubdate, publisher, series, author_sort, authors, timestamp, title, id, tags}
--timefmt
The format in which to display dates. %d - day, %b - month, %Y - year. Default is: %b, %Y
--to-dir
Export books to the specified directory. Default is .
--to-lowercase
Convert paths to lowercase.
--version
show program’s version number and exit

catalog

calibredb catalog /path/to/destination.(csv|epub|mobi|xml ...) [options]

Export a catalog in format specified by path/to/destination extension. Options control how entries are displayed in the generated catalog ouput.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.

--fields
The fields to output when cataloging books in the database. Should be a comma-separated list of fields. Available fields: all, author_sort, authors, comments, cover, formats, id, isbn, pubdate, publisher, rating, series_index, series, size, tags, timestamp, title, uuid. Default: ‘all’ Applies to: CSV, XML output formats
--help, -h
show this help message and exit
--ids, -i
Comma-separated list of database IDs to catalog. If declared, –search is ignored. Default: all
Filter the results by the search query. For the format of the search query, please see the search-related documentation in the User Manual. Default: no filtering
--sort-by
Output field to sort on. Available fields: author_sort, id, rating, size, timestamp, title. Default: ‘id’ Applies to: CSV, XML output formats
--verbose, -v
Show detailed output information. Useful for debugging
--version
show program’s version number and exit

Table Of Contents

Previous topic

calibre-smtp

Next topic

ebook-convert