Created
April 18, 2019 02:49
-
-
Save stripedpurple/5b5e311d2ec7a8dc8f1ef574d0942dbf to your computer and use it in GitHub Desktop.
Converts CBRs (Comic Book Archives) to PDFs
This file contains 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
#!/bin/bash | |
[[ $(which unrar) != /* ]] && { | |
echo Please install unrar | |
exit 1 | |
} | |
[[ $(which convert) != /* ]] && { | |
echo Please install imagemagick | |
exit 1 | |
} | |
mkdir tmp | |
for f in "$@"; do | |
mv "$f" tmp | |
cd tmp | |
unrar e -x . > /dev/null 2>../error.log | |
[[ $? -eq 0 ]] && { | |
convert *.jpg "${f%.*}.pdf" > /dev/null 2>../error.log | |
[[ $? -eq 0 ]] && { | |
rm -rf *.jpg | |
mv "${f%.*}.pdf" .. | |
echo "Successfully created ${f%.*}.pdf" | |
} || { | |
echo "Error: An error occurred while trying to create ${f%.*}.pdf" | |
} | |
} || { | |
mv "$f" .. | |
echo "Error: An error occurred while extracting the archive for $f" | |
} | |
rm -rf "$f" | |
cd .. | |
done | |
rm -rf tmp | |
[ ! -s error.log ] && rm error.log | |
echo DONE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment