Manage ebook libraries using Calibre's ebook-meta tool. Use this skill when users mention organizing ebooks, fixing book metadata, managing EPUB/MOBI/AZW files, searching their book collection, cleaning up library metadata, or working with Calibre. Also trigger for tasks involving book titles, authors, series information, ISBNs, or organizing digital reading collections.
This skill enables you to help users manage their ebook collections through Calibre's metadata tools. You can read and write ebook metadata, organize libraries, clean up missing information, and maintain well-structured book collections.
Trigger this skill when users ask about:
Before performing any ebook operations, check that Calibre and jq are installed:
scripts/check-calibre.sh
jq --version
If either is missing, provide installation instructions based on the user's platform.
Use glob patterns or find commands to discover book files:
# Find all books and audiobooks recursively
find ~/Books -type f \( -name "*.epub" -o -name "*.mobi" -o -name "*.azw" -o -name "*.azw3" -o -name "*.m4b" \)
# Find in specific directory
find ~/Books/Author\ Name -name "*.epub"
# Search by filename pattern
find ~/Books -type f -iname "*keyword*" \( -name "*.epub" -o -name "*.mobi" -o -name "*.azw" -o -name "*.azw3" -o -name "*.m4b" \)
Use the read-metadata.sh script to extract metadata from an ebook:
scripts/read-metadata.sh "/path/to/book.epub"
Note: M4B files are not supported by ebook-meta; metadata for these should be inferred from filenames or matched ebook files.
Expected JSON output:
{
"status": "success",
"file": "/path/to/book.epub",
"metadata": {
"title": "Book Title",
"author_s": "Author Name",
"authors": ["Author Name"],
"series": "Series Name",
"series_index": "1.0",
"isbn": "1234567890",
"publisher": "Publisher Name",
"published": "2024-01-01",
"language": "eng",
"comments": "Book description...",
"tags": "fiction, fantasy"
}
}
Always check the status field before processing metadata.
Use the write-metadata.sh script to update metadata:
scripts/write-metadata.sh "/path/to/book.epub" '{"title": "New Title", "authors": ["Author One", "Author Two"]}'
Only specified fields are updated; other metadata is preserved.
The skill provides three shell scripts in the scripts/ directory:
Verifies Calibre installation and returns version information.
Reads metadata from an ebook file and outputs structured JSON.
Parameters:
file_path: Path to the ebook file (supports ~ expansion)Supported formats: .epub, .mobi, .azw, .azw3
Writes metadata to an ebook file.
Parameters:
file_path: Path to the ebook filejson_metadata: JSON string with metadata fields to updateSupported metadata fields:
title: Book title (string)authors: Author names (array of strings, joined with " & ")series: Series name (string)series_index: Position in series (number, formatted as decimal)isbn: ISBN identifier (string)publisher: Publisher name (string)published: Publication date (string, YYYY-MM-DD)language: Language code (string, e.g., "eng")tags: Tags (array of strings or comma-separated string)comments: Book description (string, can contain HTML)Important notes:
When a user wants to organize their ebook collection, follow this pattern:
Directory structure:
~/Books/
├── Pierce Brown/
│ └── Red Rising/
│ ├── Red Rising (2014)/
│ │ ├── Red Rising (2014) - Pierce Brown.epub
│ │ ├── Red Rising (2014) - Pierce Brown.m4b
│ │ └── cover.jpg
│ ├── Golden Son (2015)/
│ │ ├── Golden Son (2015) - Pierce Brown.epub
│ │ └── cover.jpg
│ └── Morning Star (2016)/
│ ├── Morning Star (2016) - Pierce Brown.epub
│ └── cover.jpg
└── F. Scott Fitzgerald/
└── The Great Gatsby (1925)/
├── The Great Gatsby (1925) - F. Scott Fitzgerald.epub
└── cover.jpg
Folder structure rules:
{Author}/{Series/}{Title} ({Year})/{Title} ({Year}) - {Author}.{ext}{Author} (normalized to "Firstname Lastname"){Series} if the book is part of a series{Title} ({Year}){Title} ({Year}) - {Author}.{ext}.m4b audiobooks, cover.jpg, and other metadata files in the same Book folder using the same {Title} ({Year}) - {Author}.{ext} naming convention where possible.Implementation pattern:
# Find all relevant files
find ~/Downloads/Ebooks -type f \( -name "*.epub" -o -name "*.mobi" -o -name "*.azw" -o -name "*.azw3" -o -name "*.m4b" -o -name "*.jpg" -o -name "*.png" \)
# For each ebook file:
for file in ebook_files:
# Read metadata
result=$(./scripts/read-metadata.sh "$file")
# Parse JSON and extract author, series, title, and published (year)
# Format author as "Firstname Lastname"
# Extract year from published date (e.g., "2014-01-01" -> "2014")
# Determine target directory:
# - If series: ~/Books/{Author}/{Series}/{Title} ({Year})/
# - If no series: ~/Books/{Author}/{Title} ({Year})/
# Determine target filename: {Title} ({Year}).{ext}
# Create target directory and move ebook
mkdir -p "$target_dir"
mv "$file" "$target_dir/$target_filename"
# Find and move associated files (m4b, cover, etc.)
# Look for files with similar names in the same source directory
Handle edge cases:
{Title} ({Year}) folderWhen users want to fix missing or incorrect metadata:
Identify books needing cleanup:
# For each ebook, check for:
# - Missing title
# - Missing authors
# - Missing ISBN
# - Missing description
# - Missing series info (if applicable)
Search for book information:
# Build search query from available metadata
query="${title} ${author} book"
# Search online
remote_web_search("$query")
# Or search by ISBN for most accurate results
remote_web_search("ISBN ${isbn}")
Extract and apply updates:
Rate limiting: Add delays between web searches (2-3 seconds) to avoid being blocked.
Help users identify duplicate ebooks:
Duplicate detection criteria:
When users want to add missing information:
Reliable sources:
https://openlibrary.org/api/books?bibkeys=ISBN:{isbn}&format=json&jscmd=datahttps://www.googleapis.com/books/v1/volumes?q=isbn:{isbn}Best practices:
When a user provides a new ebook file that needs metadata updates and organization:
Example scenario: User says: "I just downloaded 'Red Rising.epub' to my Downloads folder. Can you update its metadata and add it to my library?"
Key considerations:
Anthologies contain multiple stories by different authors. The "author" field might be the editor.
Detection:
Handling:
Many books are part of a series but lack series metadata.
Detection patterns:
Enrichment:
Sometimes metadata is present but wrong.
Verification:
For books with multiple authors:
Option 1: Use first author as primary (simplest) Option 2: Create "Multiple Authors" directory Option 3: Create symlinks under each author (advanced)
Choose based on user preference and library size.
Use standard shell commands to move ebooks:
# Create target directory if it doesn't exist
mkdir -p "$(dirname "$target_path")"
# Move the file
mv "$source_path" "$target_path"
Benefits:
⚠️ WARNING: File deletion is permanent and cannot be undone.
Use rm only when:
Safer alternative: Move to archive directory instead:
mkdir -p ~/Books/.archive
mv "$file" ~/Books/.archive/
When creating file paths from metadata, sanitize names:
< > : " / \ | ? *Always check the status field in script output:
{
"status": "error",
"message": "File not found: /path/to/book.epub"
}
Common errors:
Error recovery:
Always backup before bulk operations: Warn users to backup their library before making large-scale changes.
Test on small batches first: Run workflows on 5-10 books before processing entire libraries.
Verify before writing: Read metadata first, make changes, then write back. Never blindly overwrite.
Use web sources for accuracy: Cross-reference metadata with Open Library or Google Books.
Author Name Formatting: Always use "Firstname Lastname" format for author names in library structures and metadata updates. If metadata is found in "Lastname, Firstname" format, convert it to "Firstname Lastname" before using it for file paths or writing back to the file.
Follow Calibre conventions:
Handle errors gracefully: Check status fields and continue processing on errors.
Log all changes: Keep a record of metadata changes for auditing:
echo "$(date): Updated $file" >> ~/Books/changes.log
Rate limit web requests: Add 2-3 second delays between searches to avoid being blocked.
Sanitize filenames: Remove special characters that cause filesystem issues.
Preserve originals: Consider copying instead of moving if user wants to keep original structure.
If metadata has authors in "Lastname, Firstname" format, the book might be placed in an unexpected directory. Always normalize to "Firstname Lastname":
# Example conversion: "Brown, Pierce" -> "Pierce Brown"
echo "Brown, Pierce" | awk -F', ' '{if (NF==2) print $2 " " $1; else print $0}'
Normalize series names by removing parenthetical information or subtitles.
Check file permissions and ensure target directory is writable. Verify source files aren't open in another application.
Make search queries more specific by including format and publication year:
remote_web_search("\"${title}\" \"${author}\" book epub")
Verify the file isn't read-only and check for file corruption by reading metadata after writing.
Increase delay between requests and implement exponential backoff retry logic.
When implementing these workflows:
Parse JSON carefully: Always use JSON.parse() or jq to parse script output.
Escape shell arguments: Use proper quoting for file paths and JSON strings:
scripts/read-metadata.sh "${file_path}"
scripts/write-metadata.sh "${file_path}" '${json_string}'
Handle paths with spaces: Always quote file paths in shell commands.
Check for empty results: Verify glob returns files before processing.
Provide progress updates: For batch operations, show progress to the user:
Processing book 15 of 127...
Summarize results: After batch operations, show summary:
Organized: 120 books
Skipped: 5 books (missing metadata)
Errors: 2 books (see log for details)
Ask before destructive operations: Always confirm before deleting files or overwriting metadata.
All scripts are in the scripts/ directory relative to the skill root:
scripts/check-calibre.shscripts/read-metadata.shscripts/write-metadata.shThe scripts handle platform detection (macOS vs Linux) and path expansion automatically.
This skill empowers you to help users maintain well-organized, properly-tagged ebook libraries. Focus on understanding user intent, verifying operations before execution, and providing clear feedback throughout the process. Always prioritize data safety by backing up, testing on small batches, and confirming destructive operations.
The combination of Calibre's robust metadata tools, file operations, and web search capabilities makes this skill powerful for both simple organization tasks and complex metadata enrichment workflows.