Skip to content

Instantly share code, notes, and snippets.

@konfou konfou/cbr2cbz.sh
Last active May 16, 2017

Embed
What would you like to do?
convert *.cbr to *.cbz
#!/usr/bin/env bash
#
# Convert cbr files to cbz.
# depends
type -p 7z >/dev/null || exit 3
# trap SIGINT
trap 'trap - INT; kill -s INT "$$"' INT
file() {
local base=$(basename $1 '.cbr')
7z x "$1" -o "${temp}/${base}"
7z a -tzip "${base}.cbz" "${temp}/${base}"
}
usage() {
cat <<EOF
$(basename $0) <mode> <source>
Usage:
$(basename $0) --file/-f <target> convert <target> file
$(basename $0) --dir/-d <target> convert all files in <target>
$(basename $0) --all same thing as doing --dir .
EOF
}
main() {
temp=$(mktemp -d)
case $1 in
--file|-f) file "$2" ;;
--dir|-d)
find "$2" -type f -name '*.cbr' | while read f; do
file "$f"
done ;;
--all|-a) main --dir . ;;
*) usage ;;
esac
rm -r ${temp}
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.