#!/bin/sh
for i in ?????.MTS; do
    #echo $i
    dt=`exiftool -T -H264:DateTimeOriginal $i|sed s/:/-/|sed s/:/-/|sed 's/ /T/'`

    if [ x$dt = "x-" ]; then
	echo error getting date in $i
	exit 1
    fi
    newfilename=$dt-$i
    echo "Renaming $i to $newfilename"
    if [ -f "$newfilename" ]; then
	echo "Target file name for $i does already exist"
	exit 2
    fi
    mv "$i" "$newfilename"
done
