Rotate and rename images according to their EXIF info

This is my short script to rotate and rename image files accoring to date captured based on their EXIF info.
You need jhead and exiv2 to run this. These two programs are also available in Windows and only require you to make small changes to work there as well.

#!/bin/bash -x
echo Rotating JPEG file(s)
jhead -ft -autorot D*.JPG

echo Rename(ing) file(s)
exiv2 -r '%Y%m%d-%H%M_:basename:' rename $(ls D*)

The files are then named like this (YYYYMMDD-HHDD_OriginalFileName.extension)

20120924-1320_DSC1234.JPG
20120924-1320_DSC1234.NEF
...

This script has been tested on Nikon D80 and D7000 image files.