Skip to content

Instantly share code, notes, and snippets.

@darylf
Last active August 30, 2022 03:25
Show Gist options
  • Save darylf/2828928b51ce9d1bcbc839b6f2394977 to your computer and use it in GitHub Desktop.
Save darylf/2828928b51ce9d1bcbc839b6f2394977 to your computer and use it in GitHub Desktop.
Basch Script to Convert CBR to CBZ file
#!/bin/sh
FILENAME="$1"
DIR="$(dirname "$FILENAME")"
BASENAME=$(basename "$FILENAME" .cbr)
DIR_TMP="$DIR/tmp"
echo "Converting $FILENAME"
mkdir "$DIR_TMP"
echo " Extracting $FILENAME"
unrar x -idq "$FILENAME" "$DIR_TMP"
chmod -R 777 "$DIR_TMP"
echo " Compressing $DIR/$BASENAME.cbz"
(cd "$DIR_TMP"; zip -rq "../$BASENAME.cbz" .) && chmod --reference="$DIR/$BASENAME.cbr" "$DIR/$BASENAME.cbz" && rm "$FILENAME"
rm -rf "$DIR_TMP"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment