CALIBREDB(1) calibre CALIBREDB(1)

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
  • fts_index
  • fts_search

通用選項

顯示說明訊息並退出
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
用來連線至 calibre 伺服器的密碼。要使用標準輸入中讀取密碼,請使用特殊值:<stdin>。如果要從檔案中讀取密碼,請使用:<f:/path/to/file>( 例如: <f: 檔案的完整路徑以及後置 >)。前方所寫的角括號是必須使用的,請記得在命令介面中使用跳脫字元或是引號。
透過網路連接到 calibre 書庫時的逾時時間,以秒為單位。預設值為兩分鍾。
登入Calibre網路伺服器時所用之使用者名稱
顯示程式版本編號並退出

calibredb list [options]

列出 calibre 資料庫中可用書本。

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

以遞增次序排列結果
在列出数据库中书籍时要显示的字段。应该是逗号分隔的字段列表。 可用字段: author_sort, authors, comments, cover, formats, identifiers, isbn, languages, last_modified, pubdate, publisher, rating, series, series_index, size, tags, template, timestamp, title, uuid 默认值:title,authors。特殊字段“all”可用于选择所有字段。除了上述内置字段之外,自定义字段还等价于*field_name,例如,对于自定义字段#rating,使用名称:*rating
產生適用於機器讀取用的JSON檔案,線寬及分隔符號將被忽略。
結果顯示的最大數目。預設:全部
輸出中單一行的最大寬度。預設值為偵測螢幕大小。
所有檔案路徑的前綴。預設值為書庫資料夾的絕對路徑。
以搜尋的查詢來過濾結果。要了解搜尋的查詢格式,請參閱使用者手冊中的搜尋相關文件。預設值為不做任何過濾。
用來分離欄位的字串。預設為空白。
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
The template to run if "template" is in the field list. Default: None
Path to a file containing the template to run if "template" is in the field list. Default: None
Heading for the template column. Default: template. This option is ignored if the option --for-machine is set

calibredb add [選項] file1 file2 file3 ...

加入指定檔案為書籍到資料庫。您可以指定目錄,請檢視下面目錄相關選項。

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

編輯已加入的書本作者
如果找到具有相似標題和作者的圖書,請自動將傳入格式(檔案)合併到現有圖書記錄中。值「Ignore」表示丟棄重複的格式。值「overwrite」表示書庫中的重複格式將被新加入的檔案覆蓋。值「new_record」表示將重複的格式放入新的圖書記錄中。
供已加入書本使用之書本封面路徑
即使已經存在,也加入書籍到資料庫中。 根據書名和作者進行比較。 請注意,--automerge 選項優先。
加入空的電子書(沒有格式的書本)
为这本书设置标识符,例如 -I asin:XXX -I isbn:YYY
編輯已加入的書本 ISBN
以逗號分隔的語言清單(最好使用ISO639所規範的語言格式,不過有些語言的名稱也能夠識別)
編輯已加入的書本系列
編輯已加入的書本編號
編輯已加入的書本標籤
編輯已加入的書本標題

正在從資料夾中加入

用于控制从文件夹添加书籍的选项。默认情况下,只能添加那些受支持的电子书格式类型的文件。

檔名 (glob) 模式,在掃描資料夾中的檔案時將加入與此模式相符的檔案,即使這些檔案不是已知的電子書檔案類型。可以為多個模式多次指定。
文件名模式 (glob) ,在扫描文件夹中的文件时,与此模式匹配的文件将被忽略。可以为多个模式多次指定。例如:*.pdf将忽略所有PDF文件
假设每个文件夹只有一本逻辑图书,并且其中的所有文件都是该图书的不同电子书格式
递归处理文件夹

calibredb remove ids

从数据库移除指定 id 的书籍。ids 应为以逗号分隔的 id 号列表(你可以使用搜索命令来获得 id 号)。例如,23,34,57-85(如果指定一个区间,该区间的最后一个数字不会被包括在内)。

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

不要使用 資源回收筒

calibredb add_format [options] id ebook_file

用 ebook_file 將電子書加入到由 id 標識的邏輯圖書的可用格式中。如果格式已經存在,則取代它,除非指定了不取代選項。

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

Add the file as an extra data file to the book, not an ebook format
在格式已存在時不要取代

calibredb remove_format [选项] id fmt

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

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

calibredb show_metadata [options] id

顯示在 calibre 資料庫中儲存的 id 所標識的圖書的中繼資料。 id 是來自搜尋命令的 id 編號。

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

以 OPF 格式(XML) 列印詮釋資料

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.

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

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

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). Any extra data files associated with the book are also saved. You can get id numbers from the search command.

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

導出資料庫中所有的書本,忽略 id 列表。
让calibre将所有非英文字符转换成英文对应字符的文件名。如果保存到不完全支持Unicode文件名的旧文件系统中,这将非常有用。 指定這個開關會關閉這個行為。
Normally, calibre will save the cover in a separate file along with the actual e-book files. 指定這個開關會關閉這個行為。
Save any data files associated with the book when saving the book 指定這個開關會關閉這個行為。
Normally, calibre will update the metadata in the saved files from what is in the calibre library. Makes saving to disk slower. 指定這個開關會關閉這個行為。
Normally, calibre will write the metadata into a separate OPF file along with the actual e-book files. 指定這個開關會關閉這個行為。
每本書本的格式列表,逗號間隔。預設保存所有可用格式。
报告进展
以底線替代空格。
匯出全部的書本到單一個資料夾中
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}
显示日期的格式。%d - 天, %b - 月, %m - 月数, %Y - 年。默认是: %b, %Y
匯出書本到指定的資料夾中,預設為: .
路徑轉換為小寫。

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. To see the different options, specify the name of the output file and then the --help option.

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

逗號分割資料庫 ID 到書目的列表。 一旦聲明,則忽略 --search 預設值:全部
為搜尋查詢過濾結果。搜尋查詢格式請參見使用者手冊中搜尋相關內容。預設:不過濾
顯示詳細的輸出資訊,便於除錯。

生成目录的标题用作元数据标题。 默认值:'My Books' 适用于:AZW3,ePub,MOBI 等输出格式
为具有多个作者的书籍在作者节中创建交叉引用。 默认值: 'False' 适用于: AZW3, EPUB, MOBI输出格式
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
描述以排除类型的标签正则表达式。 默认值: '[.+]|^+$' 不包括括号内的标签,例如 '[Project Gutenberg]', 和 '+', 默认的用于阅读书籍的标签。 适用于: AZW3, EPUB, MOBI 输出格式
指定用于从生成的目录中排除书籍的规则。 排除规则的模型是('<rule name>','标签','<comma-separated list of tags>') 或('<rule name>','<custom column>','<pattern>')。 例如: (('存档的书籍','#状态','已存档'),) 将在自定义列“状态”中排除值为“已存档”的图书。定义多个规则时,将应用所有规则。 默认: "(('Catalogs','Tags','Catalog'),)" 应用于AZW3, EPUB, MOBI 输出格式
目录中包括“作者”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
目录中包括“描述”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
目录中包括“类型”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
目录中包括“最近添加”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
目录中包括“丛书系列”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
目录中包括“标题”部分。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式
“类型”部分的源字段。 默认值: '標籤' 适用于: AZW3, EPUB, MOBI 输出格式
包含要在描述标头中插入的注释文本的自定义域。 默认值: '' 适用于: AZW3, EPUB, MOBI输出格式
#<custom field>:[before|after]:[True|False] 指定: <custom field> 包含与注释合并的注释的自定义字段 [before|after] 关于注释的注释放置位置 [True|False] - 在注意和注释之间插入水平规则 默认值: '::' 适用于: AZW3, EPUB, MOBI 输出格式
指定输出配置文件。在某些情况下,输出配置文件用于优化某些设备的书目分类。例如,'kindle''kindle_dx' 以章节和文章的方式来生成目录结构。默认:'None' 适用于:AZW3、EPUB、MOBI 等输出格式
--prefix-rules
指定用于包括表示已读书籍,收藏清单项目和其他用户 定前缀的前缀的规则。前缀规则的模型 ('<rule name>','<source field>','<pattern>','<prefix>')。 当定义了多个规则时,将使用第一个匹配规则 默认规则:"(('Read books','tags','+',''),('Wishlist item','tags','Wishlist','×'))"适用于:AZW3, EPUB, MOBI 输出格式
使用GUI目录生成器创建的命名预设。 预设指定用于构建目录的所有设置。 默认值: 'None' 适用于: AZW3, EPUB, MOBI 输出格式
目录中书籍封面的大小提示(英寸)。 范围: 1.0 - 2.0 默认值: '1.0' 适用于: AZW3, EPUB, MOBI 输出格式
在生成目录时替换现有的封面。 默认值: 'False' 适用于: AZW3, EPUB, MOBI 输出格式

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"

calibredb add_custom_column [options] label name datatype

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

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

一個自訂選項如何解釋該列中資料的字典。這是一個 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 的「顯示」。
這個欄位儲存類似標籤的資料(例如多個逗號分隔的數值)。只有在資料類型為文字時套用。

calibredb custom_columns [options]

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

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

顯示每個欄位的詳細資料。

calibredb remove_custom_column [options] label

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

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

不需要進行詢問確認

calibredb set_custom [options] column id value

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

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

如果欄位可存多值,將選定的屬性加入現有屬性中,而非取代。

calibredb restore_database [options]

Restore this database from the metadata stored in OPF files in each folder 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"

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

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
逗号分隔的扩展列表将被忽略。 默认值:全部
逗号分隔的名字列表将被忽略。 默认值:全部
逗号分隔的报表列表。 默认值: 全部
Vacuum the full text search database. This can be very slow and memory intensive, depending on the size of the database.

calibredb list_categories [options]

在数据库中生成一个目录信息的报告。 该信息与标签窗格中显示的信息等效。

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

逗号分隔类别列表查找名称。默认值:全部
輸出為 CSV
产生CSV文件的类型。选择:excel, excel-tab, unix
只列出每個分類中的書本總數,而不是列出每個分類中的書本。
輸出中單一行的最大寬度。預設值為偵測螢幕大小。

calibredb backup_metadata [选项]

将存储在数据库中的元数据备份到每个图书文件夹中的 单个OPF文件中。这通常是自动发生的,但是您可以运行 此命令来强制重新生成OPF文件,并使用--all选项。

请注意,通常不需要这样做,因为每次元数据更改时, OPF文件都会自动备份。

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

此命令通常僅對於過時的OPT檔案進行操作,此選項會使它在所有的書本上操作。

calibredb 複製到 path/to/new/library

建立目前書庫的副本。它建立了一個新的、空的書庫,它所有的自訂列、虛擬書庫和其他設定與目前書庫相同。

副本書庫將沒有任何書籍。如果您想要建立一個完整的副本書庫,包括所有的書籍,那麼只需使用您的檔案系統工具來複製書庫資料夾。

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

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"

只更新特定格式檔案的詮釋資料,可以指定多個檔案格式。預設值將會更新所有格式的檔案。

calibredb搜索 [选项] 搜索表达式

搜索书库中指定的搜索项,返回与搜索表达式匹配的以逗号分隔的图书ID列表。输出格式对于输入格式接受ID列表的其他命令非常有用。 搜索表达式可以是来自calibre强大的搜索查询语言中的任何内容,例如:calibredb 搜索author:asimov 'title:"i robot"'

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

結果回傳結果的最大數目。預設回傳全部結果

calibredb fts_index [options] enable/disable/status/reindex

Control the Full text search indexing process.

Turns on FTS indexing for this library
Turns off FTS indexing for this library
Shows the current indexing status
Can be used to re-index either particular books or the entire library. To re-index particular books specify the book ids as additional arguments after the reindex command. If no book ids are specified the entire library is re-indexed.

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

The speed of indexing. Use fast for fast indexing using all your computers resources and slow for less resource intensive indexing. Note that the speed is reset to slow after every invocation.
Wait till all books are indexed, showing indexing progress periodically

calibredb fts_search [options] search expression

Do a full text search on the entire library or a subset of it.

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

Only match on exact words not related words. So correction will not match correcting.
Include snippets of the text surrounding each match. Note that this makes searching much slower.
How much of the library must be indexed before searching is allowed, as a percentage. Defaults to 90
The marker used to indicate the end of a matched word inside a snippet
The marker used to indicate the start of a matched word inside a snippet
The format to output the search results in. Either "text" for plain text or "json" for JSON output.
Restrict the searched books, either using a search expression or ids. For example: ids:1,2,3 to restrict by ids or search:tag:foo to restrict to books having the tag foo.

Kovid Goyal

Kovid Goyal

3月 14, 2024 7.7.0