Display EPUB metadata and rename EPUB files accordingly
Wednesday, January 25th, 2012I’ve been programming. First a fast replacement for displaying metadata of an EPUB-file:
$ epub-meta -v 1632.epub File: 1632.epub
Title: 1632
Author: aut: Eric Flint(Flint, Eric )
ID: ISBN (Unspecified:0-671-31972-8)
ID: uuid (uuid_id:b1d2b16c-f68d-4a80-9d02-f6fcac36e1f3)
Subject: Science Fiction
Publisher: Baen Publishing Enterprises
Date: Unspecified: 2000-02-07T05:00:00+00:00
Lang: en
Contrib: bkp: calibre (0.6.51) [http://calibre.kovidgoyal.net](calibre (0.6.51) [http://calibre.kovidgoyal.net])
Meta: calibre:series_index: 1.0
Meta: calibre:timestamp: 2010-05-07T16:59:51.299000+00:00
Meta: cover: 0671578499_Cover
Meta: calibre:series: Ring of Fire
Meta: calibre:user_categories: {}
Meta: calibre:author_link_map: {}
It has commandline-switches to selectively choose which metadata should be displayed. And it does it very fast, 3ms on my system, as opposed to 670ms ebook-meta
from Calibre needs. However, it can only display the metadata, not change it. For changing metadata, you still need ebook-meta
.
Having the ability to display metadata fast, made it possible to rename EPUB-files. Initially, I had the idea to do that in C too, but working with strings is actually quite tedious in C, so I decided on perl. So there’s now also a program called epub-rename
, which renames EPUB-files according to it’s metadata in the format Author - Series SeriesIndex - Title
. Moreover, it also has, trough ebook-meta
, the ability to fix certain issues in metadata-tags. Namely change inverted Title/Author tags, fix Author-Tags which are in the wrong(!) Last, First-Format, and some more.
Well, here’s the “–help”
$ epub-rename --help
Usage:
Options:
-c|--compat
-f|--fix
-h|--help
-t|--title
-r|--rename
-x|--exchange
-v|--verbose
Options:
-c|--compat
Use ebook-meta from calibre instead of epub-meta. Much slower.
-t|--title
Fix title. This means the tag gets sanitized, as it would if
destined for a filename, and then written back to the metadata.
Uses ebook-meta.
-f|--fix
Fix all tags: author, title, and in some cases date. Uses
ebook-meta and touches every file, even those that don't need
fixing. Slow.
-h|--help
Print a brief help message and exit.
-r|--rename
rename files to the pattern "Author - Series SeriesIndex -
Title"
-x|--exchange
changes title for author-tag and vice versa. For all those files
that have the author in the title-field and the title in the
author- field. Uses ebook-meta, thus is slow.
-v|--verbose
Show how all files would be renamed, not just those really
renamed.
And here’s the program itself: epub-meta-0.2.tar.gz. MIT-Licensed. Enjoy.
If you don’t like the spaces, punctuation and UTF-8-characters in the output filenames, I’d recommend another program of mine: bicapitalize.