.. _calibredb-en:
.. raw:: html
``calibredb``
===================================================================
.. code-block:: none
calibredb command [options] [arguments]
:command:`calibredb` is the command line interface to the calibre database. It has
several sub-commands, documented below.
:command:`calibredb` can be used to manipulate either a calibre database
specified by path or a calibre :guilabel:`Content server` running either on
the local machine or over the internet. You can start a calibre
:guilabel:`Content server` using either the :command:`calibre-server`
program or in the main calibre program click :guilabel:`Connect/share ->
Start Content server`. Since :command:`calibredb` can make changes to your
calibre libraries, you must setup authentication on the server first. There
are two ways to do that:
* If you plan to connect only to a server running on the same computer,
you can simply use the ``--enable-local-write`` option of the
Content server, to allow any program, including calibredb, running on
the local computer to make changes to your calibre data. When running
the server from the main calibre program, this option is in
:guilabel:`Preferences->Sharing over the net->Advanced`.
* If you want to enable access over the internet, then you should setup
user accounts on the server and use the :option:`--username` and :option:`--password`
options to :command:`calibredb` to give it access. You can setup
user authentication for :command:`calibre-server` by using the ``--enable-auth``
option and using ``--manage-users`` to create the user accounts.
If you are running the server from the main calibre program, use
:guilabel:`Preferences->Sharing over the net->Require username/password`.
To connect to a running Content server, pass the URL of the server to the
:option:`--with-library` option, see the documentation of that option for
details and examples.
.. contents::
:local:
Global Options
~~~~~~~~~~~~~~~~~~
.. option:: --help, -h
show this help message and exit
.. option:: --library-path, --with-library
Path to the calibre library. Default is to use the path stored in the settings. You can also connect to a calibre Content server to perform actions on remote libraries. To do so use a URL of the form: http://hostname:port/#library_id for example, http://localhost:8080/#mylibrary. library_id is the library id of the library you want to connect to on the Content server. You can use the special library_id value of - to get a list of library ids available on the server. For details on how to setup access via a Content server, see https://manual.calibre-ebook.com/generated/en/calibredb.html.
.. option:: --password
Password for connecting to a calibre Content server. To read the password from standard input, use the special value: . To read the password from a file, use: (i.e. ). The angle brackets in the above are required, remember to escape them or use quotes for your shell.
.. option:: --timeout
The timeout, in seconds, when connecting to a calibre library over the network. The default is two minutes.
.. option:: --username
Username for connecting to a calibre Content server
.. option:: --version
show program\ ``'``\ s version number and exit
.. _calibredb-en-list:
list
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
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. For example: "/some path/with spaces"
.. program:: calibredb list
.. option:: --ascending
Sort results in ascending order
.. option:: --fields, -f
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, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, template, timestamp, title, uuid Default: title,authors. The special field \ ``"``\ all\ ``"``\ can be used to select all fields. In addition to the builtin fields above, custom fields are also available as \*field_name, for example, for a custom field #rating, use the name: \*rating
.. option:: --for-machine
Generate output in JSON format, which is more suitable for machine parsing. Causes the line width and separator options to be ignored.
.. option:: --limit
The maximum number of results to display. Default: all
.. option:: --line-width, -w
The maximum width of a single line in the output. Defaults to detecting screen size.
.. option:: --prefix
The prefix for all file paths. Default is the absolute path to the library folder.
.. option:: --search, -s
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.
.. option:: --separator
The string used to separate fields. Default is a space.
.. option:: --sort-by
The field by which to sort the results. You can specify multiple fields by separating them with commas. Available fields: author_sort, authors, comments, cover, formats, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, template, timestamp, title, uuid Default: id
.. option:: --template
The template to run if \ ``"``\ template\ ``"``\ is in the field list. Default: None
.. option:: --template_file, -t
Path to a file containing the template to run if \ ``"``\ template\ ``"``\ is in the field list. Default: None
.. option:: --template_heading
Heading for the template column. Default: template. This option is ignored if the option :option:`--for-machine` is set
.. _calibredb-en-add:
add
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb add [options] file1 file2 file3 ...
Add the specified files as books to the database. You can also specify folders, see
the folder related options below.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: "/some path/with spaces"
.. program:: calibredb add
.. option:: --authors, -a
Set the authors of the added book(s)
.. option:: --automerge, -m
If books with similar titles and authors are found, merge the incoming formats (files) automatically into existing book records. A value of \ ``"``\ ignore\ ``"``\ means duplicate formats are discarded. A value of \ ``"``\ overwrite\ ``"``\ means duplicate formats in the library are overwritten with the newly added files. A value of \ ``"``\ new_record\ ``"``\ means duplicate formats are placed into a new book record.
.. option:: --cover, -c
Path to the cover to use for the added book
.. option:: --duplicates, -d
Add books to database even if they already exist. Comparison is done based on book titles and authors. Note that the :option:`--automerge` option takes precedence.
.. option:: --empty, -e
Add an empty book (a book with no formats)
.. option:: --identifier, -I
Set the identifiers for this book, e.g. -I asin:XXX -I isbn:YYY
.. option:: --isbn, -i
Set the ISBN of the added book(s)
.. option:: --languages, -l
A comma separated list of languages (best to use ISO639 language codes, though some language names may also be recognized)
.. option:: --series, -s
Set the series of the added book(s)
.. option:: --series-index, -S
Set the series number of the added book(s)
.. option:: --tags, -T
Set the tags of the added book(s)
.. option:: --title, -t
Set the title of the added book(s)
Adding From Folders
^^^^^^^^^^^^^^^^^^^^^^^
Options to control the adding of books from folders. By default only files that have extensions of known e-book file types are added.
.. option:: --add
A filename (glob) pattern, files matching this pattern will be added when scanning folders for files, even if they are not of a known e-book file type. Can be specified multiple times for multiple patterns.
.. option:: --ignore
A filename (glob) pattern, files matching this pattern will be ignored when scanning folders for files. Can be specified multiple times for multiple patterns. For example: \*.pdf will ignore all PDF files
.. option:: --one-book-per-directory, -1
Assume that each folder has only a single logical book and that all files in it are different e-book formats of that book
.. option:: --recurse, -r
Process folders recursively
.. _calibredb-en-remove:
remove
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
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 search 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. For example: "/some path/with spaces"
.. program:: calibredb remove
.. option:: --permanent
Do not use the Recycle Bin
.. _calibredb-en-add_format:
add_format
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb add_format [options] id ebook_file
Add the e-book in ebook_file to the available formats for the logical book identified by id. You can get id by using the search 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. For example: "/some path/with spaces"
.. program:: calibredb add_format
.. option:: --as-extra-data-file
Add the file as an extra data file to the book, not an ebook format
.. option:: --dont-replace
Do not replace the format if it already exists
.. _calibredb-en-remove_format:
remove_format
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb remove_format [options] id fmt
Remove the format fmt from the logical book identified by id. You can get id by using the search 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. For example: "/some path/with spaces"
.. program:: calibredb remove_format
.. _calibredb-en-show_metadata:
show_metadata
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
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 search command.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: "/some path/with spaces"
.. program:: calibredb show_metadata
.. option:: --as-opf
Print metadata in OPF form (XML)
.. _calibredb-en-set_metadata:
set_metadata
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb set_metadata [options] book_id [/path/to/metadata.opf]
Set the metadata stored in the calibre database for the book identified by
book_id from the OPF file metadata.opf. book_id is a book id number from the
search 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. For example: "/some path/with spaces"
.. program:: calibredb set_metadata
.. option:: --field, -f
The field to set. Format is field_name:value, for example: :option:`--field` tags:tag1,tag2. Use :option:`--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 :option:`--field` identifiers:isbn:XXXX,doi:YYYYY. For boolean (yes/no) fields use true and false or yes and no.
.. option:: --list-fields, -l
List the metadata field names that can be used with the :option:`--field` option
.. _calibredb-en-export:
export
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb export [options] ids
Export the books specified by ids (a comma separated list) to the filesystem.
The :command:`export` operation saves all formats of the book, its cover and metadata (in
an OPF file). Any extra data files associated with the book are also saved.
You can get id numbers from the search command.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: "/some path/with spaces"
.. program:: calibredb export
.. option:: --all
Export all books in database, ignoring the list of ids.
.. option:: --dont-asciiize
Have calibre convert all non English characters into English equivalents for the file names. This is useful if saving to a legacy filesystem without full support for Unicode filenames. Specifying this switch will turn this behavior off.
.. option:: --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.
.. option:: --dont-save-extra-files
Save any data files associated with the book when saving the book Specifying this switch will turn this behavior off.
.. option:: --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.
.. option:: --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.
.. option:: --formats
Comma separated list of formats to save for each book. By default all available formats are saved.
.. option:: --progress
Report progress
.. option:: --replace-whitespace
Replace whitespace with underscores.
.. option:: --single-dir
Export all books into a single folder
.. option:: --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}
.. option:: --timefmt
The format in which to display dates. %d - day, %b - month, %m - month number, %Y - year. Default is: %b, %Y
.. option:: --to-dir
Export books to the specified folder. Default is .
.. option:: --to-lowercase
Convert paths to lowercase.
.. _calibredb-en-catalog:
catalog
~~~~~~~~~~~~~~~~~~~~
.. code-block:: none
calibredb catalog /path/to/destination.(csv|epub|mobi|xml...) [options]
Export a :command:`catalog` in format specified by path/to/destination extension.
Options control how entries are displayed in the generated :command:`catalog` output.
Note that different :command:`catalog` formats support different sets of options. To
see the different options, specify the name of the output file and then the
--help option.
Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: "/some path/with spaces"
.. program:: calibredb catalog
.. option:: --ids, -i
Comma-separated list of database IDs to catalog. If declared, :option:`--search` is ignored. Default: all
.. option:: --search, -s
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
.. option:: --verbose, -v
Show detailed output information. Useful for debugging
Epub Options
^^^^^^^^^^^^^^^^
.. option:: --catalog-title
Title of generated catalog used as title in metadata. Default: \ ``'``\ My Books\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --cross-reference-authors
Create cross-references in Authors section for books with multiple authors. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --debug-pipeline
Save the output from different stages of the conversion pipeline to the specified folder. Useful if you are unsure at which stage of the conversion process a bug is occurring. Default: \ ``'``\ None\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --exclude-genre
Regex describing tags to exclude as genres. Default: \ ``'``\ \[.+\]|^\+$\ ``'``\ excludes bracketed tags, e.g. \ ``'``\ [Project Gutenberg]\ ``'``\ , and \ ``'``\ +\ ``'``\ , the default tag for read books. Applies to: AZW3, EPUB, MOBI output formats
.. option:: --exclusion-rules
Specifies the rules used to exclude books from the generated catalog. The model for an exclusion rule is either (\ ``'``\ \ ``'``\ ,\ ``'``\ Tags\ ``'``\ ,\ ``'``\ \ ``'``\ ) or (\ ``'``\ \ ``'``\ ,\ ``'``\ \ ``'``\ ,\ ``'``\ \ ``'``\ ). For example: ((\ ``'``\ Archived books\ ``'``\ ,\ ``'``\ #status\ ``'``\ ,\ ``'``\ Archived\ ``'``\ ),) will exclude a book with a value of \ ``'``\ Archived\ ``'``\ in the custom column \ ``'``\ status\ ``'``\ . When multiple rules are defined, all rules will be applied. Default: \ ``"``\ ((\ ``'``\ Catalogs\ ``'``\ ,\ ``'``\ Tags\ ``'``\ ,\ ``'``\ Catalog\ ``'``\ ),)\ ``"``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-authors
Include \ ``'``\ Authors\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-descriptions
Include \ ``'``\ Descriptions\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-genres
Include \ ``'``\ Genres\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-recently-added
Include \ ``'``\ Recently Added\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-series
Include \ ``'``\ Series\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --generate-titles
Include \ ``'``\ Titles\ ``'``\ section in catalog. Default: \ ``'``\ False\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --genre-source-field
Source field for \ ``'``\ Genres\ ``'``\ section. Default: \ ``'``\ Tags\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --header-note-source-field
Custom field containing note text to insert in Description header. Default: \ ``'``\ \ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --merge-comments-rule
#:[before|after]:[True|False] specifying: Custom field containing notes to merge with comments [before|after] Placement of notes with respect to comments [True|False] - A horizontal rule is inserted between notes and comments Default: \ ``'``\ ::\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --output-profile
Specifies the output profile. In some cases, an output profile is required to optimize the catalog for the device. For example, \ ``'``\ kindle\ ``'``\ or \ ``'``\ kindle_dx\ ``'``\ creates a structured Table of Contents with Sections and Articles. Default: \ ``'``\ None\ ``'``\ Applies to: AZW3, EPUB, MOBI output formats
.. option:: --prefix-rules
Specifies the rules used to include prefixes indicating read books, wishlist items and other user-specified prefixes. The model for a prefix rule is (\ ``'``\ \ ``'``\ ,\ ``'``\