CALIBREDB(1)

NAME
calibredb - calibredb

calibredb command [options] [arguments]

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

calibredb can be used to manipulate either a calibre database specified by path or a calibre Content server running either on the local machine or over the internet. You can start a calibre Content server using either the calibre-server program or in the main calibre program click Connect/share  → Start Content server. Since 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 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 --username and --password options to calibredb to give it access. You can setup user authentication for 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 Preferences → Sharing over the net → Require username/password.

    To connect to a running Content server, pass the URL of the server to the --with-library option, see the documentation of that option for details and examples.

•   全局选项

•   list

•   add

•   从目录中添加

•   remove

•   add_format

•   remove_format

•   show_metadata

•   set_metadata

•   export

•   catalog

•   EPUB 设置

•   saved_searches

•   add_custom_column

•   custom_columns

•   remove_custom_column

•   set_custom

•   restore_database

•   check_library

•   list_categories

•   backup_metadata

•   clone

•   embed_metadata

•   search

全局选项

--help, -h
    显示此帮助信息并退出

--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.

--password
    Password for connecting to a calibre Content server. To read the password from standard input, use the special value: <stdin>. To read the password from a file, use: <f:/path/to/file>.)

--username
    连接到 calibre 内容服务器的用户名

--version
    显示程序版本号并退出

LIST

calibredb list [options]

列出 Calibre 数据库中可用书籍。

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--ascending
    升序排列结果

--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, 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

--for-machine
    以 JSON 格式输出，更适合机器解析。忽略每行长度和分隔符选项。

--limit
    结果显示的最大数目。默认；全部

--line-width, -w
    输出中单行宽度最大值。默认检测屏幕大小。

--prefix
    所有文件路径前缀。默认为书库目录绝对路径。

--search, -s
    通过搜索请求过滤结果。对于每个搜索请求的格式，请参见用户手册中搜索相关的文档。默认为不做过滤。

--separator
    分隔各个字段的字符串。默认是空格。

--sort-by
    排列结果所用字段。 可用字段：author_sort, authors, comments, cover, formats, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, timestamp, title, uuid 默认：id

ADD

calibredb add [options] file1 file2 file3 ...

添加指定文件为书籍到数据库。您可以指定目录，请查看下面目录相关选项。

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--authors, -a
    设置已添加书籍的作者

--cover, -c
    设置已添加书籍的封面路径

--duplicates, -d
    即使书籍已经存在于数据库仍然添加。通过书名进行区分。

--empty, -e
    添加空白书籍(无格式书籍)

--identifier, -I
    设置这本书的标识符，例如 -I asin:XXX -I isbn:YYY

--isbn, -i
    设置已添加书籍的 ISBN

--languages, -l
    逗号分割的语言列表（最好使用 ISO639 语言代码，即使有些语言名称也能识别）

--series, -s
    为添加的书籍设置丛书

--series-index, -S
    为添加的书籍设置丛书编号

--tags, -T
    设置已添加书籍的标签

--title, -t
    设置已添加书籍的标题

  从目录中添加

控制从文件夹中添加书籍的选项。默认情况下，只有已知扩展名的电子书类型才会被添加。

--add
    当文件扫描目录时，即使它们不是已知的电子书文件类型，文件名（全局）模式，匹配此模式的文件将被添加。可以多次指定多个模式。

--ignore
    当文件扫描目录时，文件名（全局）模式，匹配此模式的文件将被忽略。,可以多次指定多个模式。,例如：* .pdf将忽略所有pdf文件

--one-book-per-directory, -1
    假设每个目录只有一本逻辑书籍，而所有文件均是该书的不同格式电子书

--recurse, -r
    递归处理目录

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 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”

--permanent
    不使用回收站

ADD_FORMAT

calibredb add_format [options] id ebook_file

将ebook_file中的电子书添加到由id标识的逻辑书籍的可用格式。您可以使用搜索命令获取ID。如果格式已经存在，它将被替换，除非指定不替换选项。

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--dont-replace
    如果该格式已存在则不做替换.

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 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”

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 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”

--as-opf
    以 OPF 表单(XML)打印元数据

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 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”

--field, -f
    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.

--list-fields, -l
    List the metadata field names that can be used with the --field option

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 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”

--all
    导出数据库中所有的书籍，忽略 id 列表。

--dont-asciiize
    一般来说，Calibre 为文件名将所有非英文字符转换为英文对应字符。警告：若关闭此项，您可能保存文件出错，取决于您的文件系统是否支持 unicode。 选定此项将关闭此操作。

--dont-save-cover
    一般来说，Calibre 将把封面保存为单独文件，和原始电子书文件分开保存。 选定此项将关闭此操作。

--dont-update-metadata
    一般来说，Calibre 将基于 Calibre 书库升级存储所存文件的元数据。这使保存到磁盘变慢一些。 选定此项将关闭此操作。

--dont-write-opf
    一般来说，Calibre 将会把元数据写入单独的 OPF 文件，和原始电子书文件分开保存。 选定此项将关闭此操作。

--formats
    每本书籍的格式列表，逗号间隔。默认保存所有可用格式。

--replace-whitespace
    下划线替换空格。

--single-dir
    导出所有书籍到单个目录

--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: {author_sort, authors, id, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, tags, timestamp, title}

--timefmt
    The format in which to display dates. %d - day, %b - month, %m - month number, %Y - year. Default is: %b, %Y

--to-dir
    导出书籍到指定目录。默认为 .

--to-lowercase
    将路径转为小写。

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 output. Note that different catalog formats support different sets of options.

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--ids, -i
    逗号分割数据库 ID 到书目的列表。 一旦声明，则忽略 --search 默认值：全部

--search, -s
    为搜索查询过滤结果。搜索查询格式请参见用户手册中搜索相关内容。默认：不过滤

--verbose, -v
    显示详细输出信息。有利调试

  EPUB 设置

--catalog-title
    Title of generated catalog used as title in metadata. Default: 'My Books' Applies to: AZW3, EPUB, MOBI output formats

--cross-reference-authors
    Create cross-references in Authors section for books with multiple authors. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--debug-pipeline
    Save the output from different stages of the conversion pipeline to the specified directory. 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

--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

--exclusion-rules
    Specifies the rules used to exclude books from the generated catalog. The model for an exclusion rule is either ('<rule name>','Tags','<comma-separated list of tags>') or ('<rule name>','<custom column>','<pattern>'). 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

--generate-authors
    Include 'Authors' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--generate-descriptions
    Include 'Descriptions' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--generate-genres
    Include 'Genres' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--generate-recently-added
    Include 'Recently Added' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--generate-series
    Include 'Series' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--generate-titles
    Include 'Titles' section in catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

--genre-source-field
    Source field for 'Genres' section. Default: '标签' Applies to: AZW3, EPUB, MOBI output formats

--header-note-source-field
    Custom field containing note text to insert in Description header. Default: '' Applies to: AZW3, EPUB, MOBI output formats

--merge-comments-rule
    #<custom field>:[before|after]:[True|False] specifying: <custom field> 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

--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

--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 ('<rule name>','<source field>','<pattern>','<prefix>'). When multiple rules are defined, the first matching rule will be used. Default: "(('Read books','tags','+','✓'),('Wishlist item','tags','Wishlist','×'))" Applies to: AZW3, EPUB, MOBI output formats

--preset
    Use a named preset created with the GUI catalog builder. A preset specifies all settings for building a catalog. Default: 'None' Applies to: AZW3, EPUB, MOBI output formats

--thumb-width
    Size hint (in inches) for book covers in catalog. Range: 1.0 - 2.0 Default: '1.0' Applies to: AZW3, EPUB, MOBI output formats

--use-existing-cover
    Replace existing cover when generating the catalog. Default: 'False' Applies to: AZW3, EPUB, MOBI output formats

SAVED_SEARCHES

calibredb saved_searches [options] (list|add|remove)

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.

Syntax for adding:

calibredb saved_searches add search_name search_expression

Syntax for removing:

calibredb saved_searches remove search_name

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

ADD_CUSTOM_COLUMN

calibredb add_custom_column [options] label name datatype

创建一个自定义的栏目，栏目名为您自定义的名称，不能包含空格或冒号。数据类型可为：bool, comments, composite, datetime, enumeration, float, int, rating, series, text

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--display
    用于自定义此列中的数据将如何解释的选项字典。这是一个JSON字符串。对于枚举列，请使用:option:–display =“{”enum_values “：[”val1 “，”val2 “]}” ,有很多选项可以进入显示变量。列类型的选项是： 复合：composite_template，composite_sort，make_category，contains_html，use_decorations ,datetime：date_format ,枚举：enum_values，enum_colors，use_decorations ,int，float：number_format ,text：is_names，use_decorations ,查找合法组合的最佳方式是在GUI中创建适当类型的自定义列，然后查看书的备份OPF（确保从列添加以来已创建新的OPF）。您将看到OPF中新列的“显示”的JSON。

--is-multiple
    此列存储类似数据的标签(即多个逗号分隔值)。仅适用于数据类型为文本。

CUSTOM_COLUMNS

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. For example: “/some path/with spaces”

--details, -d
    每栏显示细节。

REMOVE_CUSTOM_COLUMN

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. For example: “/some path/with spaces”

--force, -f
    无需确认

SET_CUSTOM

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 search 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. For example: “/some path/with spaces”

--append, -a
    如果栏存有多个值，将指定值附加到已有值之后，而非覆盖。

RESTORE_DATABASE

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. For example: “/some path/with spaces”

--really-do-it, -r
    Really do the recovery. The command will not run unless this option is specified.

CHECK_LIBRARY

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. For example: “/some path/with spaces”

--csv, -c
    以 CSV 输出

--ignore_extensions, -e
    忽略的扩展使用逗号分隔列表. 默认:全部

--ignore_names, -n
    忽略的名称使用逗号分隔列表. 默认:全部

--report, -r
    报告使用逗号分隔列表. 默认:全部

LIST_CATEGORIES

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. For example: “/some path/with spaces”

--categories, -r
    Comma-separated list of category lookup names. Default: all

--csv, -c
    以 CSV 输出

--dialect
    生成为 CSV 文件类型. 挑选: excel, excel-tab

--item_count, -i
    Output only the number of items in a category instead of the counts per item within the category

--width, -w
    输出中单行宽度最大值。默认检测屏幕大小。

BACKUP_METADATA

calibredb backup_metadata [选项]

单独备份元数据储存到数据库到每个 OPF 文件书库。 此项默认自动发生,但是你可以运行此命令来重新生成 OPF 文件,还可以用 –all 选项.

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. For example: “/some path/with spaces”

--all
    通常，此命令仅对过时的OPF文件的书籍进行操作。该选项会使它在所有的书籍上操作。

CLONE

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. For example: “/some path/with spaces”

EMBED_METADATA

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. For example: “/some path/with spaces”

--only-formats, -f
    Only update metadata in files of the specified format. Specify it multiple times for multiple formats. By default, all formats are updated.

SEARCH

calibredb search [options] search expression

Search the library for the specified search term, returning a comma separated list of book ids matching the search expression. The output format is useful to feed into other commands that accept a list of ids as input.

The search expression can be anything from calibre’s powerful search query language, for example: author:asimov title:robot

Whenever you pass arguments to calibredb that have spaces in them, enclose the arguments in quotation marks. For example: “/some path/with spaces”

--limit, -l
    返回结果显示的最大数目，默认为全部。

AUTHOR
Kovid Goyal

COPYRIGHT
Kovid Goyal