Created
December 4, 2017 17:43
-
-
Save scottchiefbaker/8fb6ea3b3f59463d12ba7d6bb02da59c to your computer and use it in GitHub Desktop.
Convert .cbr to .cbz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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