manipulating filenames

By Hal Canary, 2004-03-04 12:27:41 (link)

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.

## $HOME/bin/rename-files ##
for FILE in img_????.jpg ; do
    X=( `stat  -c %y $FILE ` )
    mv -v "$FILE" "$DATE-$FILE"