1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/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 |