diff --git a/cbz/cbr2cbz b/cbz/cbr2cbz new file mode 100644 index 0000000..08fcd98 --- /dev/null +++ b/cbz/cbr2cbz @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +usage(){ + printf 'Usage: %s [files...]\n' "$0" + exit 64 # sysexits.h(3) EX_USAGE +} + +command -v zip \ + >/dev/null \ + && command -v unrar \ + >/dev/null + +test -n "$1" \ + || usage + +d="$(mktemp -d || printf '%s/.cbr2cbz\n' "$HOME/")" +if test -n "$DEBUG" +then set -x; d=x +else trap 'rm -rf "$d"; trap - EXIT; exit' EXIT INT HUP +fi + +while test -n "$1"; do + unrar x -op"$d" "$1" + zip -Z deflate "$1".cbz "$d"/* +done