Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # put this file and xbiso.pl in the directory with your xbox game folders
- # warning, this code does not handle spaces in file or directory names
- # Checks CRC, keeps log
- # Unpacks rar/iso doesn't clean up
- startdir=`pwd`
- startdate=`date +%Y%m%d%H%M%S`
- startdate2=`date +%c`
- logfile=${startdir}"/unrar2-"${startdate}".log"
- logheader="Unrar2.sh run from:\n"${startdir}"\n\nThe following games failed the unrar CRC Check:\n\n\n"
- logfooter="\nLog created on: "
- logcount=0
- logcountfail=0
- logcountpass=0
- for f in `find . -type f`
- do
- foundpath=`dirname $f`
- foundname=`basename $f`
- # Will find *.001 or *.rar, including *part01.rar or *part001.rar
- # but never "part", proceeded by a number greater then 01 or 001, then ending in ".rar"
- if [[ $foundname = *.rar || $foundname = *.001 ]]; then
- if [[ $foundname = *part01.rar ||
- $foundname = *part001.rar ||
- $foundname = *.001 ||
- $foundname = !(*part[0-9][0-9]|*part[0-9][0-9][0-9]).rar ]]; then
- cd $startdir/$foundpath
- currentdir=${PWD##*/}
- echo "FOUND! $currentdir"
- ((logcount = logcount + 1))
- # CRC check
- printf 'Verifying rar...'
- if [[ `unrar t -inul $foundname; echo $?` = 0 ]]; then
- ((logcountpass = logcountpass + 1))
- printf 'PASS\n'
- # unrar
- echo "Unpacking rar..."
- unrar x -inul $foundname
- # unpack iso
- echo "Unpacking iso..."
- isofile=`find . -iname '*.iso'`
- perl $startdir/xbiso.pl -f $isofile -d Files >/dev/null 2>&1
- # rename iso, will be the same name as the parent dir
- echo "Renaming iso..."
- mv $isofile $currentdir.iso
- else # crc fail
- ((logcountfail = logcountfail + 1))
- printf 'FAIL\n'
- if [[ $logcountfail = 1 ]]; then
- echo -e $logheader >> $logfile
- fi
- echo -e $currentdir "\n" >> $logfile
- fi # crc end
- echo "----------------"
- fi # pack first rar end
- fi # find rar end
- done # find all files end
- enddate=`date +%Y%m%d%H%M%S`
- echo -e "FINISHED!\nPass count: "${logcountpass}"\nFail count: "${logcountfail}
- if [[ $logcountfail > 0 ]]; then
- echo -e "\n\nTotal fail count: "${logcountfail} >> $logfile
- echo -e $logfooter $startdate2 >> $logfile
- echo "See log for more details"
- fi
Advertisement
Add Comment
Please, Sign In to add comment