-
-
Save Max-T/1dc5842e1aa296c3957473d33b42cedb to your computer and use it in GitHub Desktop.
Zepub: Shell Script to Package & Validate ePub Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # zepub.sh 0.1 | |
| # Package & Validate ePub Files | |
| # by @robot_media (http://www.robotmedia.net) | |
| # thanks to @lizcastro (http://www.elizabethcastro.com/epub/) | |
| # | |
| # INSTRUCTIONS | |
| # | |
| # Make zepub.sh executable: chmod +x zepub.sh | |
| # Optional: to validate the resulting ePub files change the validator_path variable below. | |
| # | |
| # EXAMPLES | |
| # | |
| # sh zepub book.epub | |
| # sh zepub book.epub /my/epub/folder | |
| # Path to EpubCheck (http://code.google.com/p/epubcheck) | |
| validator_path="/path/to/epubcheck/epubcheck-1.2.jar" | |
| function usage () { | |
| cat <<EOF | |
| Usage: zepub output [input] | |
| EOF | |
| } | |
| # Output argument | |
| if [ -z "$1" ]; then | |
| usage | |
| exit 0 | |
| fi | |
| output=$1 | |
| # Remove existing output | |
| rm -f $output | |
| # Input argument | |
| if [ -n "$2" ]; then | |
| input=$2 | |
| else | |
| input="." | |
| fi | |
| # Package | |
| initial=$PWD | |
| cd $input | |
| zip -0Xq $initial/$output mimetype | |
| zip -Xr9Dq $initial/$output * -x zepub.sh *.epub *.DS_Store | |
| echo $output | |
| # Validate | |
| if [ -f $validator_path ]; then | |
| cd $initial | |
| java -jar $validator_path $output | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment