Hi, I'm having trouble getting batch execution to wait for UFRaw to finish processing...

The problem is that this script should sequentially process all the selected files. Because it doesn't wait for UFRaw to finish (ie: for me to manually process the NEF), it opens all the selected Raw files at once, quickly eating up all my RAM!

I'd appreciate any tips!

here's the script:

#!/bin/bash
#Script to create e-mail and web sized JPEG versions of RAW files
#2005, Dennis Meulensteen

DIR=nef
DIRO=Output

#Loop through all the selected files
for A in "$@"
do
    #(re)calculate the relative Output dir and filename
    DIRO="$(dirname "$A")/$DIR/""$DIRO"
    FILO="$(dirname "$A")/$DIR/$(basename "$A" .jpg).nef"
   
    echo "$A" &>"$0".log
    echo "$DIRO" &>"$0".log
    echo "$FILO" &>"$0".log
   
    if [ ! -f "$FILO" ]
        then echo "There is no related NEF File!" &>"$0".log
    fi
   
    #create the Output dir if needed
    if [ ! -d "$DIRO" ]
        then mkdir "$DIRO" &>"$0".log
    fi

    echo "process: $(dirname "$A")/$DIR/$(basename "$A" .jpg).nef" &>"$0".log
   
    ufraw --interpolation=full --shrink=1 --out-type=jpeg --compression=100 --out-path="$DIRO" "$FILO"
    wait
done

exit