EPUB Notes
Look Inside
How to get at the contents of a .epub file? Simple:
unzip foo.epub
You’ll see the HTML files that make up the EPUB file, along with some metadata.
Creating a new EPUB file
Say you want to change some things in your EPUB file - perhaps the CSS or the index. You unzipped the file and made your changes. How do you put it together into a new EPUB file?
From a look at this article, I get the idea that an EPUB file is (roughly) just a bunch of HTML files zipped the right way.
So let’s do that.
As per the instructions in that article, this is all you need:
epub_name=foo.epub
zip -X $epub_name mimetype
zip -rg $epub_name META-INF
zip -rg $epub_name * -x \*.epub META-INF mimetype
Make sure that the file doesn’t exist already, just to be safe. The mimetype file is special. Put it alone first with -X
. Then, put the META-INF directory (recursively with -r
). Put everything else. The -g
tells zip to grow the existing archive instead of creating a new one. The -x
tells zip
to ignore the files you’ve already put in.
comments powered by Disqus