manipulating filenames

gphoto2 grabs images off of my camera and saves it as IMG_XXXX.JPG. I use the despacify script to convert to lowercase img_XXXX.jpg. Then I run this script to rename th file to include the date the photo was taken: 2003-11-06-img-XXXX.jpg. Then if the filesystem modification date is changed (e.g. if I rotate it.) I will still know when it originated.

#!/bin/sh
## $HOME/bin/rename-files ##
for FILE in img_????.jpg ; do
    X=( `stat  -c %y $FILE ` )
    DATE=${X[0]}
    mv -v "$FILE" "$DATE-$FILE"
done