#!/bin/bash output() { file=$1 while read line do echo $line echo $line >> $file done } DIR="$1" if [ a"$DIR" = a ]; then echo "No directory given" exit fi if [ ! -d "$DIR" ]; then echo "$DIR is not a directory, skipping..." exit fi shopt -s nullglob echo "Working in $DIR" cd "$DIR" if [ ! -z [cC][dD]1 ]; then echo "`date`: Detecting CD's unraring..." | output result for i in [cC][dD]? do cd $i echo "`date`: working in directory $i, unraring..." | output ../result rar -kb -o- e *.rar *.001 2>&1 | output ../result cd .. done mv */* . rmdir * &>/dev/null else echo "`date`: working in directory `pwd`, unraring..." | output result rar -kb -o- e *.rar *.001 2>&1 | output result cd .. fi for i in *.bin do newname=`echo "$i" | sed "s/.bin$/.mpg/"` echo "`date`: ripping mpeg from $i to $newname" | output result if [ -e track_00.mpg ]; then echo "`date`: track_00.mpg already present, quitting..." | output result exit fi if [ -e "$newname" ]; then echo "`date`: $newname already present, skipping..." | output result continue fi vcdxrip -p -v -b "$i" 2>&1 | output result /bin/mv -b avseq01.mpg "$newname" done echo "`date`: done" | output result