#!/bin/bash

# Usage: zzufsol <indir> <outdir> <min> <max>
# Will create corrupted SOL files from all the .sol files in <indir>
# using zzuf seeds from <min> to <max> and write them to <outdir>

if test -z "$4"; then
	echo "Usage: $0 <indir> <outdir> <min> <max>" >&2
	exit 1
fi

ls $1/*.sol | { 
while read r; do
	echo "$r"
    count=$3
    while [ $count -le $4 ]
    do
        f=`md5sum "$r" | sed 's/  .*$//;'`.sol
        echo "$count-$f"
        zzuf -s$count < "$r" > "$2/$count-$f"
        count=$[$count+1]
    done
done
}
