If you can improve it, please feel free to post a better revision and I'll update the post.
Code: Select all
count=0
index=1
cd $1
for file in *.sfv; do
let count+=1
done
if [ $count -gt 1 ]; then
for file in *.sfv; do
total_filesize=0
basename=`echo $file | head -c -5`
for rarfile in $basename*; do
[ -f "$rarfile" ] || continue
filesize=$(stat -c %s "$rarfile")
((total_filesize += filesize))
done
if [ $total_filesize -lt 744488960 ]; then # 710MB
media="CD"
else
media="DVD"
fi
if [ -f "$file" ]; then
if [ ! -d $media$index ]; then
mkdir -v $media$index
fi
mv -v $basename* $media$index
fi
let index+=1
done
fi
Disclaimer: I make no guarantees that this code will work or that it will not harm your data, your machine, your family, or anything else.
Mills