Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author: Nate Stokes
- # License: GPL3+
- # Based on a blog entry by Alon Ivtsan
- #
- #
- # mycolor='\033[0;30m' - colorise echo output to make it pretty!!
- # Notes 15/4 - Apparently I should be using tput instead of ascii escapes, but they no worky.
- # Notes 1/05/15 - Forked to add imagemajik scale function, because I've been getting heaps of broken cbr/cbz that are
- # fine on the computer, but won't display on Android. My solution for this is to basically batch rename and very slightly
- # resize the image files in between unrarring and rezipping - Seems to be working ok so far.
- # Intentions - To extend teh suite of scripts to fix without converting, convert and rename without resizing, etc etc.
- # Notes 06/05/15 - After struggling like hell to get the bigger comics to convert while still being able to use my
- # machine, I've gotten looping working properly with teh image scaling thingy. Now I'll want to see if it's faster on
- # small files, or if I should have a big file and a small file version of the script.
- #
- #
- # The purpose of this file is to extract a cbz file, rename the content files based to the original cbz name,
- # scale the image by a very small amount to negate the integrity issue with CBZ readers on Android and rearchive
- # in CBZ format.
- #
- #
- # Color escapes for prettiness
- red='\033[1;31m'
- green='\033[1;32m'
- blue='\033[1;34m'
- purple='\033[1;35m'
- NC='\033[0m' #no color - return echo to default
- # Variables
- COUNTER=0
- tick=0
- BACKUP='original_cbrs'
- # Attempt at using tput #
- #red='tput setaf 1'
- #green='tput setaf 2'
- #blue='tput setaf 3'
- #purple='tput setaf 4'
- #NC='tput sgr0'
- mkdir "$BACKUP"; #Stick the old files out of the way once converted
- for FILE in *{.cbr,.CBR}
- do
- [ -e "$FILE" ] || continue
- #echo -e "${red}**Converting ${green} $FILE ${red} to cbz format:${NC}"
- DIR="${FILE%.*}"
- mkdir "$DIR";
- mkdir "$DIR"/temp;
- echo -e "${blue}-Unrar ${green} $FILE ${NC}"
- unrar e ./"$FILE" ./"$DIR"/temp;
- mv "$FILE" ./"$BACKUP"/;
- cd "$DIR"/temp;
- nice -n 19 convert -verbose -resize 95% '*.jpg' ../"$DIR"-%03d.jpg;
- # for i in *.jpg;
- # do
- # nice -n 19 convert -limit memory 5GiB -verbose -resize 95% "$i" ../a-"$DIR"-`printf %03d $tick`.jpg;
- # tick=$((tick + 1))
- # done
- cd ../..;
- rm -r "$DIR"/temp;
- echo -e "${purple}-Zipping Up: ${green} $DIR ${NC}"
- zip -rq "$DIR".cbz "$DIR";
- rm -r "$DIR";
- # Now Move CBR File to the old directory
- COUNTER=$((COUNTER + 1))
- echo -e "${red}Conversion of ${green} $FILE ${red} successful!"
- echo -e "${red} --Old CBR Copy Of ${green} $FILE ${red} Moved To ${blue}/old ${red}--${NC}\n"
- done
- echo -e "${red}All Files Completed, ${green} $COUNTER ${red} Files Converted.${NC}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement