Last active
August 29, 2015 14:05
-
-
Save Shahor/953b60a48a2621c8d3ff to your computer and use it in GitHub Desktop.
ebook converter
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
#!/usr/bin/env bash | |
if ! type "ebook-convert" > /dev/null; then | |
echo "ebook-convert tool not found in your PATH. Please install it (via Calibre) and re-run this script"; | |
exit | |
fi | |
# Pass a path as first argument | |
function convert { | |
for file in "$1"/* | |
do | |
if [ -d "$file" ] | |
then | |
convert "$file" | |
else | |
fileExtension=`echo "$file" | awk -F . '{print $NF}'` | |
if [ "$fileExtension" = "epub" ] | |
then | |
mobiname=`dirname "$file"`/`basename "$file" .epub`.mobi | |
if [ ! -f "$mobiname" ] | |
then | |
ebook-convert "$file" "$mobiname" | |
fi | |
fi | |
fi | |
done | |
} | |
cd `dirname $0` | |
convert . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment