Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert .cbr to .cbz
#!/bin/bash
# Turn on super debug mode
#set -x
for i in "$@"
do
# Store the current directory
od=$PWD
#a=$(mktemp --directory) && cd $a
# Create a scratch directory in /dev/shm for speed
a="/dev/shm/$(uuidgen)"
mkdir $a && cd $a
echo "Processing $i"
# Unrar the files
unrar x "$od/$i" 2>&1 > /dev/null
# Create a zipfile with the same file structure
zipfile=${i/.cbr/.cbz}
zip -9qr "$zipfile" .
# Move the created file back to the previous directory
cd - 2>&1 > /dev/null
mv "$a/$zipfile" .
# Delete the scratch dir
rm -Rf $a
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment