Skip to content

Instantly share code, notes, and snippets.

@Exagone313
Created October 11, 2017 23:50
Show Gist options
  • Save Exagone313/6d9ef6c096d685f475d0a2cef161d374 to your computer and use it in GitHub Desktop.
Save Exagone313/6d9ef6c096d685f475d0a2cef161d374 to your computer and use it in GitHub Desktop.
Convert cbr to cbz (comic book archives)
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
# depends on p7zip (7z command) with rar support
# should be compatible with bash (tested on zsh)
# for batch call:
# find -name '*.cbr' -print -exec zsh -c 'source ~/.zshrc;cbr2cbz "{}"' \;
function cbr2cbz() {
TMP="$XDG_RUNTIME_DIR"
CBZ=$(basename "$1" .cbr).cbz
DN=$(dirname "$1")
if [ -f "$DN/$CBZ" ]; then
echo "$DN/$CBZ already exists"
else
echo "Will create $DN/$CBZ"
DIR=$(mktemp -d -p "$TMP")
7z x "$1" -o"$DIR"
find "$DIR" -type f -print -exec 7z a -tzip "$DN/$CBZ" {} \;
rm -rf "$DIR"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment