Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
convert books to mobis
#!/bin/bash
# quick script to convert books to .mobi and put in a designated dir called mobi/
for d in */; do
if [[ $d == "mobis" ]]; then continue; fi
cd "$d"
mobi=$(ls | grep 'mobi$')
epub=$(ls | grep 'epub$')
pdf=$(ls | grep 'pdf$')
if [[ -n $mobi ]]; then
echo "copying mobi"
cp "$mobi" ../mobis/
elif [[ -n $epub ]]; then
echo "convert epub"
name=${epub%.*}.mobi
ebook-convert "$epub" "../mobis/$name"
elif [[ -n $pdf ]]; then
echo "convert pdf"
name=${pdf%.*}.mobi
ebook-convert "$pdf" "../mobis/$name"
fi
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment