
: Re: Command line extraction of metadata (title. author) from epub file I would like to use a command line to extract the title of a book (possibly also other metadata) from its epub file and return
Here's a quick bash script (with no error-checking whatsoever) to do what you want:
#!/bin/bash
#
if [ $# -lt 3 ]
then
echo
echo "Usage: minfo -m <meta-type> <epub-file>"
echo
else
fileloc=`unzip -l "" | grep -Po 'b[^s-]*.opfb'`
metafound=`zipgrep '<dc:''>(.*)</dc:''>' "" $fileloc`
echo `expr "$metafound" : '.*<dc:''>(.*)</dc:''>.*'`
fi
This uses unzip -l to find out where the .opf file is in the .epub (normally OEBPScontent.opf, but it can be named anything as long as it has the .opf extension). Then it uses zipgrep to find occurrences of the desired metadata type in that file. Finally, strip off the tags to leave just the metadata.
And here's a test run:
beaker$ ./minfo -m title Make_Electronics.epub
Make: Electronics
beaker$ ./minfo -m publisher Make_Electronics.epub
O'Reilly Media, Inc.
beaker$ ./minfo -m subject Make_Electronics.epub
beaker$
That last line is blank because the metadata entry for subject in the opf file is:
<dc:subject/>
Free books android app tbrJar TBR JAR Read Free books online gutenberg
More posts by @Melissa

: How to manage my e-book library across my devices So I have a reasonable collection of ebooks, and it starts to be a mess. My collection is a mixture of ebooks from Amazon (Kindle) and pdf.

: How to download ebooks from Kindle to PC? I'm am trying to download some Kindle eBooks that I have bought to my laptop. I tried connecting my Kindle to my PC via USB and then try to access