{"id":403,"date":"2012-01-25T16:58:05","date_gmt":"2012-01-25T15:58:05","guid":{"rendered":"\/Blog\/?p=403"},"modified":"2013-10-03T16:07:12","modified_gmt":"2013-10-03T15:07:12","slug":"display-epub-metadata-and-rename-epub-files-accordingly","status":"publish","type":"post","link":"https:\/\/seegras.discordia.ch\/Blog\/display-epub-metadata-and-rename-epub-files-accordingly\/","title":{"rendered":"Display EPUB metadata and rename EPUB files accordingly"},"content":{"rendered":"<p>I&#8217;ve been programming. First a fast replacement for displaying metadata of an EPUB-file:<br \/>\n<code><br \/>\n$ epub-meta -v 1632.epub File: 1632.epub<br \/>\nTitle: 1632<br \/>\nAuthor: aut: Eric Flint(Flint, Eric )<br \/>\nID: ISBN (Unspecified:0-671-31972-8)<br \/>\nID: uuid (uuid_id:b1d2b16c-f68d-4a80-9d02-f6fcac36e1f3)<br \/>\nSubject: Science Fiction<br \/>\nPublisher: Baen Publishing Enterprises<br \/>\nDate: Unspecified: 2000-02-07T05:00:00+00:00<br \/>\nLang: en<br \/>\nContrib: bkp: calibre (0.6.51) [http:\/\/calibre.kovidgoyal.net](calibre (0.6.51) [http:\/\/calibre.kovidgoyal.net])<br \/>\nMeta: calibre:series_index: 1.0<br \/>\nMeta: calibre:timestamp: 2010-05-07T16:59:51.299000+00:00<br \/>\nMeta: cover: 0671578499_Cover<br \/>\nMeta: calibre:series: Ring of Fire<br \/>\nMeta: calibre:user_categories: {}<br \/>\nMeta: calibre:author_link_map: {}<br \/>\n<\/code><br \/>\nIt 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  <code>ebook-meta<\/code> from Calibre needs. However, it can only display the metadata, not change it. For changing metadata, you still need <code>ebook-meta<\/code>. <\/p>\n<p>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&#8217;s now also a program called <code>epub-rename<\/code>, which renames EPUB-files according to it&#8217;s metadata in the format <code>Author - Series SeriesIndex - Title<\/code>. Moreover, it also has, trough <code>ebook-meta<\/code>, the ability to fix certain issues in metadata-tags. Namely change inverted Title\/Author tags, fix Author-Tags which are in the wrong(!) <em>Last, First<\/em>-Format, and some more.  <\/p>\n<p>Well, here&#8217;s the &#8220;&#8211;help&#8221;<br \/>\n<code>$ epub-rename --help<br \/>\nUsage:\n    <this program> [options] [directory ...]<\/p>\n<p>     Options:<br \/>\n       -c|--compat<br \/>\n       -f|--fix<br \/>\n       -h|--help<br \/>\n       -t|--title<br \/>\n       -r|--rename<br \/>\n       -x|--exchange<br \/>\n       -v|--verbose<\/p>\n<p>Options:<br \/>\n    -c|--compat<br \/>\n            Use ebook-meta from calibre instead of epub-meta. Much slower.<\/p>\n<p>    -t|--title<br \/>\n            Fix title. This means the tag gets sanitized, as it would if<br \/>\n            destined for a filename, and then written back to the metadata.<br \/>\n            Uses ebook-meta.<\/p>\n<p>    -f|--fix<br \/>\n            Fix all tags: author, title, and in some cases date. Uses<br \/>\n            ebook-meta and touches every file, even those that don't need<br \/>\n            fixing. Slow.<\/p>\n<p>    -h|--help<br \/>\n            Print a brief help message and exit.<\/p>\n<p>    -r|--rename<br \/>\n            rename files to the pattern \"Author - Series SeriesIndex -<br \/>\n            Title\"<\/p>\n<p>    -x|--exchange<br \/>\n            changes title for author-tag and vice versa. For all those files<br \/>\n            that have the author in the title-field and the title in the<br \/>\n            author- field. Uses ebook-meta, thus is slow.<\/p>\n<p>    -v|--verbose<br \/>\n            Show how all files would be renamed, not just those really<br \/>\n            renamed.\n<\/this><\/code><\/p>\n<p>And here&#8217;s the program itself: <a href=\"http:\/\/seegras.discordia.ch\/Programs\/epub-meta-0.2.tar.gz\">epub-meta-0.2.tar.gz<\/a>. MIT-Licensed. Enjoy. <\/p>\n<p>If you don&#8217;t like the spaces, punctuation and UTF-8-characters in the output filenames, I&#8217;d recommend another program of mine: <a href=\"http:\/\/seegras.discordia.ch\/Programs\/bicapitalize\">bicapitalize<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commandline programs to display EPUB metadata, and to rename EPUB-files according to the metadata. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,96,98],"tags":[],"class_list":["post-403","post","type-post","status-publish","format-standard","hentry","category-computers","category-ebooks","category-metadata"],"_links":{"self":[{"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/comments?post=403"}],"version-history":[{"count":6,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/posts\/403\/revisions"}],"predecessor-version":[{"id":683,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/posts\/403\/revisions\/683"}],"wp:attachment":[{"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/media?parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/categories?post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seegras.discordia.ch\/Blog\/wp-json\/wp\/v2\/tags?post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}