A chronological documentation test project, nothing serious, really!

17 Jul 2012 Rename AVCHD files using Exiftools

Posted by

Simple bash script to rename AVCHD/MTS/MOV files to match their recording date and time.

if [ -z "$1" ]; then
echo "Usage: ./ FILETYPE" 1>&2
echo "Example: ./ *.MTS" 1>&2
exit 1
for x in "$@"
exiftool '-FileName<DateTimeOriginal' -d %Y%m%d_%H%M_%%f.%%e "$x"

The resulting files will be named like YYYYMMDD_HHMM_BASENAME.ext ie 20120703_1635_05600.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_%%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.

Tags: , , , ,

Reader's Comments

  1. |

    Great !

    This works also with MTS files created with Sony HDR-CX250E recorder.

    Thanks you.

  2. |

    I have changed the command and added an extra % in a Windows batch file to

    C:\exiftool.exe "-FileName<DateTimeOriginal" -d "%%Y%%m%%d-%%H%%M_%%%%-f.%%%%e" *.MTS

    to have a result file like


    • |

      I have some MOV-files from a Panasonic Lumix DMC-ZX1 that will not be renamed with the exiftool command above. Instead I have used
      exiftool "-FileName<CreateDate" -d "%%Y%%m%%d_%%H%%M_%%%%f.%%%%e" *.MOV
      replacing the DateTimeOriginal with the CreateDate option.