The above is likely to produce errors as it assumes you'll have at least four sets of files in there any time it's run.
I'd think it would be better to leave something in memory instead. That way it will know where it last moved a file.
Code:
#!/bin/sh
TARGETLIST="a:b:c:d"
INTERVAL=60 # seconds
targetnum=1
targetlistsize=`echo $TARGETLIST | sed 's/[^:]//g' | wc -c`
while true
do
for mpf in *.mpf
do
files="$mpf `echo $mpf | sed 's/f$/e/'` `echo $mpf | sed 's/f$/d/'`"
if ls $files > /dev/null 2>&1
then
mv $files `echo $TARGETLIST | cut -d ':' -f $targetnum`
targetnum=`expr $targetnum % $targetlistsize`
targetnum=`expr $targetnum + 1`
fi
done
sleep $INTERVAL
done
However, are you sure you are looking at the right problem? Could you not use a striped volume across those 4 devices instead?