Posted by Hans-Henry Jakobsen
Simple bash script to rename AVCHD/MTS/MOV files to match their recording date and time.
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: ./rename_video.sh FILETYPE" 1>&2
echo "Example: ./rename_video.sh *.MTS" 1>&2
exit 1
fi
for x in "$@"
do
exiftool '-FileName<DateTimeOriginal' -d %Y%m%d_%H%M%S_%%f.%%e "$x"
done
The resulting files will be named like YYYYMMDD_HHMMSS.ext ie 20120703_005600.MTS
Exiftools can also be used to perform the renaming process in Windows as well using a command window
# exiftool "-FileName<DateTimeOriginal" -d %Y%m%d_%H%M%S_%%f.%%e *.MTS
This script has been tested on Canon Legria and on Panasonic HDC-SD800 video camera MTS-files and Nikon D7000 MOV-files with great success.
Great !
This works also with MTS files created with Sony HDR-CX250E recorder.
Thanks you.
I have changed the command to
exiftool ‘-FileName<DateTimeOriginal’ -d %Y%m%d-%H%M_%%-f.%%e *.MTS
to have a result file like
20120922-1415_DSC_6177.MTS