Skip to content

Instantly share code, notes, and snippets.

@scottchiefbaker
Created December 4, 2017 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottchiefbaker/8fb6ea3b3f59463d12ba7d6bb02da59c to your computer and use it in GitHub Desktop.
Save scottchiefbaker/8fb6ea3b3f59463d12ba7d6bb02da59c to your computer and use it in GitHub Desktop.
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