While I like Calibre (and still plan to use it for ingesting books), I grew dissatisfied with Calibre-Web (and Calibre-Web-Automated). I liked Komga and wanted to switch, but didn't want to spend time painfully migrating my library to the structure Komga likes. So I asked my buddy Claude(.ai) to help me write a migration script. After some back and forth and tweaks, this is the result. So yes, it's 100% AI coded, but 1) it's non-desctructive to your Calibre library and 2) it's at least been tested by me a bit. That being said, if you see something/run into issues, by all means raise an issue and we'll work on it.
A Python script that migrates ebooks from Calibre's folder structure to Komga's expected format, making it easy to transition your ebook library to Komga's comic/ebook server.
- Backup First: Always backup your libraries before migration
- Non-destructive: Original Calibre library remains unchanged
- File Conflicts: Existing files in destination are skipped with warnings
- Series Only: Books without
.epubor.kepubformats are skipped (Komga only reads epub files so no need to migrate the rest) - Metadata: Only ebook files are copied; metadata and cover files are excluded
This script reads Calibre's metadata database to accurately organize books by series and converts the folder structure from Calibre's Author/Title/files format to Komga's flat Series/files format.
π Calibre Library/
βββ π Brandon Sanderson/
β βββ π The Way of Kings (45)/
β β βββ π The Way of Kings.epub
β βββ π Words of Radiance (22)/
β β βββ π Words of Radiance.epub
β βββ π Warbreaker (178)/
β βββ π Warbreaker.epub
π Komga Library/
βββ π Brandon Sanderson - The Stormlight Archive/
β βββ π Volume 01 - The Way of Kings.epub
β βββ π Volume 02 - Words of Radiance.epub
βββ π Brandon Sanderson/
βββ π Warbreaker.epub
- β Database-driven: Uses Calibre's SQLite database for accurate series detection
- β Series organization: Groups books properly using Calibre's series metadata
- β Volume numbering: Maintains correct order using series index from Calibre
- β Title cleaning: Removes Calibre's auto-generated numbering suffixes (e.g., "(84)")
- β
Format filtering: Only migrates
.epuband.kepubfiles - β Dry run mode: Preview changes before migration
- β Author filtering: Migrate specific authors only
- β Cross-platform: Works on Windows, macOS, and Linux
- β Safe migration: Preserves original files, copies to new location
- Python 3.6 or higher
- Access to a Calibre library folder
- Destination folder for Komga library
- Download the
calibre2komga.pyscript - Ensure Python 3.6+ is installed on your system
- No additional dependencies required (uses Python standard library only)
python calibre2komga.py /path/to/calibre/library /path/to/komga/libraryPreview what will be migrated without making any changes:
python calibre2komga.py /path/to/calibre/library /path/to/komga/library --dry-runpython calibre2komga.py /path/to/calibre/library /path/to/komga/library --author "Brandon Sanderson"python calibre2komga.py /path/to/calibre/library /path/to/komga/library --verbosepython calibre2komga.py /path/to/calibre/library /path/to/komga/library --dry-run --author "Isaac Asimov" --verbose| Option | Description |
|---|---|
calibre_path |
Path to your Calibre library directory (required) |
komga_path |
Path to your Komga library directory (required, will be created if doesn't exist) |
--dry-run |
Show what would be migrated without copying files |
--author "Name" |
Filter migration to specific author (case insensitive partial match) |
--verbose |
Enable detailed logging output |
- Reads Calibre Database: Connects to
metadata.dbto extract book metadata, series information, and series indices - Series Detection: Uses Calibre's series metadata for accurate grouping, falls back to title pattern matching for standalone books
- Folder Structure: Creates series folders and places files directly inside (no subfolders)
- File Naming: Renames files to include volume information for series books
- Format Filtering: Only processes
.epuband.kepubfiles
- Folder:
Author - Series Name - Files:
Volume XX - Book Title.epub
Example: Brandon Sanderson - Mistborn/Volume 01 - The Final Empire.epub
- Folder:
Author Name - Files:
Book Title.epub
Example: Brandon Sanderson/Warbreaker.epub
The script provides detailed statistics after completion:
Migration Summary:
Total books found: 1,247
Books migrated: 1,198
Books skipped: 45
Errors: 4
Success rate: 96.1%
- Ensure you're pointing to the root Calibre library folder
- The folder should contain a
metadata.dbfile
- Book only has formats other than
.epubor.kepub - Consider converting books in Calibre first if needed
- Ensure you have read access to Calibre library
- Ensure you have write access to destination folder
Disclaimer: This script is not officially affiliated with Calibre or Komga projects. Use at your own risk and always backup your data before migration.