Scroll to navigation

CALIBREDB(1) calibre CALIBREDB(1)

NAME

calibredb - calibredb

calibredb command [选项] [参数]


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
calibre 库的路径。默认是使用存储在设置中的路径。您还可以连接到 calibre 内容服务器,以便在远程库上执行操作。为此使用表单的URL:http://hostname:port/#library_id 例如,http://localhost:8080/#mylibrary。library_id是要在内容服务器上连接的库的库id。您可以使用特殊的library_id值来获得服务器上可用库id的列表。有关如何通过内容服务器设置访问的详细信息,请参阅https://manual.calibre-ebook.com/generated/en/calibredb.html。

--password
连接到 calibre 内容服务器的密码。若要从标准输入读取密码,请使用特殊值:<stdin>。若要从文件读取密码,请使用<f:/path/to/file>(即<f:后跟文件的完整路径和尾随>)。上面的角括号是必需的,记住要脱掉它们,或者使用引号。

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

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

LIST

calibredb list [选项]


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

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--ascending
升序排列结果

--fields, -f
在列出数据库中书籍时要显示的字段。应该是逗号分隔的字段列表。 可用字段: author_sort, authors, comments, cover, formats, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, timestamp, title, uuid 默认值:title,authors。特殊字段“all”可用于选择所有字段。除了上述内置字段之外,自定义字段还等价于*field_name,例如,对于自定义字段#rating,使用名称:*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 [选项] file1 file2 file3 ...


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

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/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
文件名 (glob) 模式,与此模式匹配的文件将在扫描文件目录时添加,即使它们不是已知的电子书文件类型。可以为多个模式多次指定。

--ignore
文件名 (glob) 模式,与此模式匹配的文件将在扫描文件目录时被忽略。可以为多个模式多次指定。例如:*.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).

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--permanent
不使用回收站

ADD_FORMAT

calibredb add_format [options] id ebook_file


用 ebook_file将电子书添加到由id标识的逻辑书的可用格式中。如果格式已经存在,则替换它,除非指定了不替换选项。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--dont-replace
如果格式已经存在不要替换它

REMOVE_FORMAT

calibredb remove_format [选项] id fmt


从ID识别的逻辑书中删除fmt格式。你可以通过使用搜索命令获取ID。fmt应该是形如LRF或TXT或EPUB的一个文件扩展名。如果逻辑书没有fmt可用则什么也不做。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

SHOW_METADATA

calibredb show_metadata [options] id


显示在 calibre 数据库中存储的id所标识的图书的元数据。 id是来自搜索命令的id号。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

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

SET_METADATA

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


根据OPF文件的metadata.opf设置存储在 calibre 数据库中的用于标识图书的元数据。 id是来自搜索命令的id号。您可以通过使用--as-opf切换到show_metadata命令来快速 了解OPF格式。还可以用--field选项设置各个字段的元数据。如果使用--field选项则 不需要指定OPF文件。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--field, -f
设置字段。格式是field_name:value,例如:--field tags:tag1,tag2。使用:option:--list-fields`来获取所有字段名称的列表。你可以多次指定此选项来设置多个字段。注意:对于语言,你必须使用ISO639语言代码(例如en代表英文,fr代表法语等)。对于标识符,语法是:option:--field` identifiers:isbn:XXXX,doi:YYYYY。对于布尔(是/否)字段使用真与假或是和否。

--list-fields, -l
列出可用于:option:
`
    
--field`选项的元数据字段名称

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.

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/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
每本书籍的格式列表,逗号间隔。默认保存所有可用格式。

--progress
报告进展

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

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

--template
模板用来控制保存到设备的文件的文件名和目录结构。默认是"{author_sort}/{title}/{title} - {authors}",它将把书籍保存到包含标题和作者的文件名的每个作者目录中。可用的控制项是: {author_sort, authors, id, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, tags, timestamp, title}

--timefmt
显示日期的格式。%d - 天, %b - 月, %m - 月数, %Y - 年。默认是: %b, %Y

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

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

CATALOG

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


按路径/到/目的扩展指定格式输出目录。 选项控制如何在生成的目录输出中显示条目。 注意,不同的目录格式支持不同的选项集。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

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

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

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

EPUB 个选项

--catalog-title
生成目录的标题用作元数据标题。 默认值:'My Books' 适用于:AZW3,ePub,MOBI 等输出格式

--cross-reference-authors
为具有多个作者的书籍在作者节中创建交叉引用。 默认值: 'False' 适用于: AZW3, EPUB, MOBI输出格式

--debug-pipeline
在转换过程的不同阶段分别保存输出到指定目录。 默认: 'None' 适用于: AZW3, EPUB, MOBI 的输出格式

--exclude-genre
描述以排除类型的标签正则表达式。 默认值: '[.+]|^+$' 不包括括号内的标签,例如 '[Project Gutenberg]', 和 '+', 默认的用于阅读书籍的标签。 适用于: AZW3, EPUB, MOBI 输出格式

--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
目录中包括“作者”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--generate-descriptions
目录中包括“描述”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--generate-genres
目录中包括“类型”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--generate-recently-added
目录中包括“最近添加”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--generate-series
目录中包括“丛书系列”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--generate-titles
目录中包括“标题”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

--genre-source-field
“类型”部分的源字段。 默认值: '标签' 适用于: AZW3, EPUB, MOBI 输出格式

--header-note-source-field
包含要在描述标头中插入的注释文本的自定义域。 默认值: '' 适用于: AZW3, EPUB, MOBI输出格式

--merge-comments-rule
#<custom field>:[before|after]:[True|False] 指定: <custom field> 包含与注释合并的注释的自定义字段 [before|after] 关于注释的注释放置位置 [True|False] - 在注意和注释之间插入水平规则 默认值: '::' 适用于: AZW3, EPUB, MOBI 输出格式

--output-profile
指定输出配置文件。在某些情况下,输出配置文件用于优化某些设备的书目分类。例如,'kindle''kindle_dx' 以章节和文章的方式来生成目录结构。默认:'None' 适用于:AZW3、EPUB、MOBI 等输出格式

--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
使用GUI目录生成器创建的命名预设。 预设指定用于构建目录的所有设置。 默认值: 'None' 适用于: AZW3, EPUB, MOBI 输出格式

--thumb-width
目录中书籍封面的大小提示(英寸)。 范围: 1.0 - 2.0 默认值: '1.0' 适用于: AZW3, EPUB, MOBI 输出格式

--use-existing-cover
在生成目录时替换现有的封面。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

SAVED_SEARCHES

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


管理存储在该数据库中的保存搜索。 如果尝试添加已经存在的一个名称查询, 则它将被替换。

添加语法:

calibredb saved_searches add search_name search_expression

删除语法:

calibredb saved_searches remove search_name

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/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

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--display
一个自定义选项如何解释该列中数据的字典。这是一个JSON字符串。对于枚举列,使用 --display"{\ "enum_values\ ":[\ "val1\ ", \ "val2\ "]}" 有许多选项可以进入显示变量,按列类型的选项是: 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 找到适当组合的最好方法是在GUI中创建适当类型的自定义列,然后查看图书的备份OPF(确保自从添加该列以来已经创建了新的OPF)。在OPF中的新列中,你将看到JSON的“显示”。

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

CUSTOM_COLUMNS

calibredb custom_columns [options]


列出可用的自定义列。显示列标签和ids。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

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

REMOVE_CUSTOM_COLUMN

calibredb remove_custom_column [options] label


用标签删除的自定义列标识。可以使用custom_columns command命令查看可用列

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--force, -f
无需确认

SET_CUSTOM

calibredb set_custom [options] column id value


为 id 标识的书设置自定义列的值。 您可以使用搜索命令获取 id 列表。 您可以使用 custom_columns 命令获取自定义列名的列表。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/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.

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--really-do-it, -r
确认做恢复。除非指定了此选项,否则命令不会运行。

CHECK_LIBRARY

calibredb check_library [options]


对表示库的文件系统执行一些检查。生成报告是invalid_titles, extra_titles, invalid_authors, extra_authors, missing_formats, extra_formats, extra_files, missing_covers, extra_covers, failed_folders

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--csv, -c
以 CSV 输出

--ignore_extensions, -e
逗号分隔的扩展列表将被忽略。 默认值:全部

--ignore_names, -n
逗号分隔的名字列表将被忽略。 默认值:全部

--report, -r
逗号分隔的报表列表。 默认值: 全部

LIST_CATEGORIES

calibredb list_categories [options]


在数据库中生成类别信息的报告。信息等同于标签窗格中显示的内容。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--categories, -r
逗号分隔类别列表查找名称。默认值:全部

--csv, -c
以 CSV 输出

--dialect
产生CSV文件的类型。选择:excel, excel-tab

--item_count, -i
只输出类别中的项目数目,而不是类别内的每项计数

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

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--all
通常,此命令只对过时的OPF文件书籍进行操作。这个选项可使它在所有的书籍上运行。

CLONE

calibredb clone path/to/new/library


创建当前图书库的克隆。创建一个全新的,没有书籍的图书库,和之前的图书库保持同样的定制的栏目,虚拟图书库,以及其他设置。 这个克隆的图书库不包含任何书籍。如果你想要一个完整的复制,包括所有的书籍,那么,你只需要用系统提供的拷贝工具,拷贝整个图书库的目录就行了。

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

EMBED_METADATA

calibredb embed_metadata [options] book_id


从 calibre 数据库中的元数据更新存储在 calibre 库中的实际图书文件中的元数据。 通常,只有从 calibre 导出文件时才更新元数据,如果希望文件就地更新,则此命 令很有用。请注意,不同的文件格式支持不同数量的元数据。你可以使用book_id 的特殊值“all”来更新所有书籍中的元数据。还可以指定许多由空间分隔的书籍ID 和由连字符分隔的ID范围。例如:calibredb embed_metadata 1 2 10-15 23

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--only-formats, -f
只更新指定格式的文件中的元数据。为多种格式指定多次。默认情况下,所有格式都会更新。

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

每当向具有它们自己空间的calibredb传递参数时,用引号括起这些参数。例如: "/some path/with spaces"

--limit, -l
返回的最大结果数。默认是所有结果。

AUTHOR

Kovid Goyal

COPYRIGHT

Kovid Goyal
二月 01, 2019 3.39.1