Very strange, I've tested the script with some dummy files and it works on my linux box.
Try inserting some echo commands in the script and try to re-run it:
Code:
#!/bin/bash
# Set the video directory here
VIDEO_ROOT_DIRECTORY="/Users/astrid/NFS/scripts/img2iso"
for imgfile in `find "$VIDEO_ROOT_DIRECTORY" -name "*.img" -type f`
do
echo "Processing IMGFILE <$imgfile>"
n=0
exit=""
suffix=""
while [ ! "$exit" ]
do
newname=`echo "$imgfile" | sed "s/\.img$/$suffix\.iso/"`
if [ ! -f "$newname" ]
then
echo "NEW NAME OK! Renaming to <$newname>"
mv "$imgfile" "$newname"
exit="y"
else
echo "NEW NAME <$newname> already exists! Incrementing suffix"
n="$((n+1))"
suffix="-$n"
fi
done
You can also run the script with "sh -x img2iso.sh" to trace the execution.