Skip to content

Instantly share code, notes, and snippets.

@lmas
Created August 5, 2023 18:26
Show Gist options
  • Save lmas/a9abc3d5248426807c4427e6026a89a3 to your computer and use it in GitHub Desktop.
Save lmas/a9abc3d5248426807c4427e6026a89a3 to your computer and use it in GitHub Desktop.
Convert CBR files to CBZ
#!/bin/sh
set -e pipefail
# Converts all CBR files in current dir to CBZ
# Source:
# https://ubuntuforums.org/showthread.php?t=1273762&s=a388d691ed1d259329dc26304528a056&p=8676006#post8676006
convert() {
dir=$(pwd)
cbr="$1"
name=$(basename "$cbr" .cbr)
tmpdir=$(mktemp -d)
cd "$tmpdir"
unrar e -inul "$dir/$cbr"
zip -q "$dir/$name.cbz" ./*
cd "$dir"
rm -rf "$tmpdir"
}
for f in *.cbr; do
echo "converting $f"
convert "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment