calibredb command [options] [arguments]
calibredb is the command line interface to the calibre database. It has several sub-commands, documented below:
Do not notify the running calibre GUI (if any) that the database has changed. Use with care, as it can lead to database corruption!
Path to the calibre library. Default is to use the path stored in the settings.
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.
Sort results in ascending order
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,identifiers,isbn,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.
Generate output in JSON format, which is more suitable for machine parsing. Causes the line width and separator options to be ignored.
show this help message and exit
The maximum number of results to display. Default: all
The maximum width of a single line in the output. Defaults to detecting screen size.
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.
The string used to separate fields. Default is a space.
The field by which to sort the results. Available fields: publisher,series_index,formats,isbn,uuid,pubdate,rating,series,timestamp,author_sort,cover,comments,identifiers,last_modified,authors,title,tags,size Default: None
show program’s version number and exit
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.
Set the authors of the added book(s)
Path to the cover to use for the added book
Add books to database even if they already exist. Comparison is done based on book titles.
Add an empty book (a book with no formats)
show this help message and exit
Set the ISBN of the added book(s)
A comma separated list of languages (best to use ISO639 language codes, though some language names may also be recognized)
Assume that each directory has only a single logical book and that all files in it are different e-book formats of that book
Process directories recursively
Set the series of the added book(s)
Set the series number of the added book(s)
Set the tags of the added book(s)
Set the title of the added book(s)
show program’s version number and exit
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 (when specifying a range, the last number in the range is not included).
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
show this help message and exit
show program’s version number and exit
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, unless the do not replace option is specified.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Do not replace the format if it already exists
show this help message and exit
show program’s version number and exit
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.
show this help message and exit
show program’s version number and exit
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.
Print metadata in OPF form (XML)
show this help message and exit
show program’s version number and exit
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. You can also set the metadata of individual fields with the –field option. If you use the –field option, there is no need to specify an OPF file.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
The field to set. Format is field_name:value, for example: --field tags:tag1,tag2. Use --list-fields to get a list of all field names. You can specify this option multiple times to set multiple fields. Note: For languages you must use the ISO639 language codes (e.g. en for English, fr for French and so on). For identifiers, the syntax is --field identifiers:isbn:XXXX,doi:YYYYY. For boolean (yes/no) fields use true and false or yes and no.
show this help message and exit
show program’s version number and exit
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.
Export all books in database, ignoring the list of ids.
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.
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.
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.
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.
Comma separated list of formats to save for each book. By default all available formats are saved.
show this help message and exit
Replace whitespace with underscores.
Export all books into a single directory
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: {publisher, series_index, isbn, pubdate, rating, series, author_sort, languages, authors, last_modified, timestamp, title, id, tags}
The format in which to display dates. %d - day, %b - month, %m - month number, %Y - year. Default is: %b, %Y
Export books to the specified directory. Default is .
Convert paths to lowercase.
show program’s version number and exit
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 output.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
The fields to output when cataloging books in the database. Should be a comma-separated list of fields. Available fields: all, title, title_sort, author_sort, authors, comments, cover, formats, id, isbn, library_name, ondevice, pubdate, publisher, rating, series_index, series, size, tags, timestamp, uuid, languages, identifiers, plus user-created custom fields. Example: --fields=title,authors,tags Default: ‘all’ Applies to: CSV, XML output formats
show this help message and exit
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
Output field to sort on. Available fields: author_sort, id, rating, size, timestamp, title_sort Default: ‘id’ Applies to: CSV, XML output formats
Show detailed output information. Useful for debugging
show program’s version number and exit
calibredb saved_searches [options] list
calibredb saved_searches add name search calibredb saved_searches remove name
Manage the saved searches stored in this database. If you try to add a query with a name that already exists, it will be replaced.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
show this help message and exit
show program’s version number and exit
calibredb add_custom_column [options] label name datatype
Create a custom column. label is the machine friendly name of the column. Should not contain spaces or colons. name is the human friendly name of the column. datatype is one of: rating, int, text, float, comments, datetime, composite, bool, enumeration, series
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
A dictionary of options to customize how the data in this column will be interpreted. This is a JSON string. For enumeration columns, use --display=“{“enum_values”:[“val1”, “val2”]}” There are many options that can go into the display variable.The options by column type are: composite: composite_template, composite_sort, make_category,contains_html, use_decorations datetime: date_format enumeration: enum_values, enum_colors, use_decorations int, float: number_format text: is_names, use_decorations The best way to find legal combinations is to create a custom column of the appropriate type in the GUI then look at the backup OPF for a book (ensure that a new OPF has been created since the column was added). You will see the JSON for the “display” for the new column in the OPF.
show this help message and exit
This column stores tag like data (i.e. multiple comma separated values). Only applies if datatype is text.
show program’s version number and exit
calibredb custom_columns [options]
List available custom columns. Shows column labels and ids.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Show details for each column.
show this help message and exit
show program’s version number and exit
calibredb remove_custom_column [options] label
Remove the custom column identified by label. You can see available columns with the custom_columns command.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Do not ask for confirmation
show this help message and exit
show program’s version number and exit
calibredb set_custom [options] column id value
Set the value of a custom column for the book identified by id. You can get a list of ids using the list command. You can get a list of custom column names using the custom_columns command.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
If the column stores multiple values, append the specified values to the existing ones, instead of replacing them.
show this help message and exit
show program’s version number and exit
calibredb restore_database [options]
Restore this database from the metadata stored in OPF files in each directory of the calibre library. This is useful if your metadata.db file has been corrupted.
WARNING: This command completely regenerates your database. You will lose all saved searches, user categories, plugboards, stored per-book conversion settings, and custom recipes. Restored metadata will only be as accurate as what is found in the OPF files.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
show this help message and exit
Really do the recovery. The command will not run unless this option is specified.
show program’s version number and exit
calibredb check_library [options]
Perform some checks on the filesystem representing a library. Reports are invalid_titles, extra_titles, invalid_authors, extra_authors, missing_formats, extra_formats, extra_files, missing_covers, extra_covers, failed_folders
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Output in CSV
show this help message and exit
Comma-separated list of extensions to ignore. Default: all
Comma-separated list of names to ignore. Default: all
Comma-separated list of reports. Default: all
show program’s version number and exit
calibredb list_categories [options]
Produce a report of the category information in the database. The information is the equivalent of what is shown in the tags pane.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Comma-separated list of category lookup names. Default: all
Output in CSV
show this help message and exit
Output only the number of items in a category instead of the counts per item within the category
The character to put around the category value in CSV mode. Default is quotes (”).
The string used to separate fields in CSV mode. Default is a comma.
show program’s version number and exit
The maximum width of a single line in the output. Defaults to detecting screen size.
calibredb backup_metadata [options]
Backup the metadata stored in the database into individual OPF files in each books directory. This normally happens automatically, but you can run this command to force re-generation of the OPF files, with the –all option.
Note that there is normally no need to do this, as the OPF files are backed up automatically, every time metadata is changed.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
Normally, this command only operates on books that have out of date OPF files. This option makes it operate on all books.
show this help message and exit
show program’s version number and exit
calibredb clone path/to/new/library
Create a clone of the current library. This creates a new, empty library that has all the same custom columns, virtual libraries and other settings as the current library.
The cloned library will contain no books. If you want to create a full duplicate, including all books, then simply use your filesystem tools to copy the library folder.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
show this help message and exit
show program’s version number and exit
calibredb embed_metadata [options] book_id
Update the metadata in the actual book files stored in the calibre library from the metadata in the calibre database. Normally, metadata is updated only when exporting files from calibre, this command is useful if you want the files to be updated in place. Note that different file formats support different amounts of metadata. You can use the special value ‘all’ for book_id to update metadata in all books. You can also specify many book ids separated by spaces and id ranges separated by hyphens. For example: calibredb embed_metadata 1 2 10-15 23
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks.
show this help message and exit
Only update metadata in files of the specified format. Specify it multiple times for multiple formats. By default, all formats are updated.
show program’s version number and exit