#!/bin/rc # repack .cbr as .cbz, try to fix the file names # requires linuxemu for unrar rfork e fn fixname{ sed ' s/( |\+|%C2)/_/g; s/(%A0|%0A|%22|%23|%25|%26|%28|%3D|%3F|%5B|%5D|%5E|\(|\)|\'')//g; s/(__|___)/_/g; ' } fn usage { echo 'usage: crip [ -cdnrz ]' >[1=2] exit usage } zip=(zip -v -f) switch($1){ case -c for(i in *.cbr){ wdir=`{pwd} file=`{echo $"i | urlencode | fixname | sed 's/\.cbr$/\.cbz/g'} dir=`{echo $"file | sed 's/\.cbz$//g'} mkdir crip.$file && cd crip.$file && unrar x $"wdir'/'$"i && crip -n && cd $wdir && mv crip.$file $dir && eval $zip $file $dir && rm -r $dir && rm $"i && echo $file } case -d for(i in `{ls | grep -v -e '\.cb(r|z)'}){ file=`{echo $"i | urlencode | fixname} if(! ~ $i $file) mv $"i $file eval $zip $file.cbz $file && rm -rf $file echo $file.cbz } case -n for(i in *){ file=`{echo $"i | urlencode | fixname} if(! ~ $i $file) mv $"i $file echo $file } case -r for(i in *.rar){ file=`{echo $"i | urlencode | fixname | sed 's/\.rar$/\.cbr/g'} if(! ~ $i $file) mv $"i $file echo $file } case -z for(i in *.zip){ file=`{echo $"i | urlencode | fixname | sed 's/\.zip$/\.cbz/g'} if(! ~ $i $file) mv $"i $file echo $file } case * usage }