bell notificationshomepageloginedit profileclubsdmBox

10% popularity   0 Reactions

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


Load Full (0)

Login to follow story

More posts by @Melissa

0 Comments

Sorted by latest first Latest Oldest Best

 

Back to top