Saturday, 9 March 2013

How To: Renaming AVI movie files using the Date and Time the movie was digitized

I am fanatical about storing my photos and home videos on my NAS using the date and time they were taken so that any media renderer will naturally sort them chronologically. It also takes any guesswork out of figuring out when the movie or photo was taken as it's simply the file name i.e. 20110824-100559 being 2011, August 24th @ 10:05:59 AM. See my other post here that shows how I use "Lupas Rename 2000" to automatically do this for hundreds (or even thousands) of photos in seconds.

Recently I found some older AVI files that had been recorded on my retired Canon S2 digital camera. The associated THM (thumbnail) file that has the date and time the movie was created had been deleted so I needed a way to extract the date and time directly from the AVI file. Again, I use the excellent EXIF Tool by Phil Harvey to accomplish this task. A little tweak on the command line for the code I used to rename my IOS MOV files and we're underway.

Exiftool Installation for Windows 7/8
  • Download the excellent ExifTool by Phil Harvey here. Use the "Windows Executable" version.
  • Extract the program and rename the exe from 'exiftool(-k).exe' to 'exiftool.exe'
  • Move the 'exiftool.exe' program to C:\Windows
  • Further installation instructions here
Now to rename your AVI movie files using the date and time the movie was taken (the IDIT 26 Tag).
  • Copy the code below to the clipboard (highlight and use CRTL +C) exiftool "-filename<${datetimeoriginal}" -ext AVI -d "%Y%m%d-%H%M%S.%%e" . (don't forget the space and fullstop at the end)
  • Navigate to the folder where you have the movies stored. Don't enter the folder itself as you need to be selecting the folder in the next step
  • Hold down the 'Shift' key and right click the folder containing the movies pegged for renaming
  • Select 'Open command window here'
  • Right click and choose paste to drop in the exiftool code
  • Hit enter
  • After a period of time (see below), the command window will give you a report of the scan process

  • Your movies are now renamed using the date and
How much stuff is in the folder dictates the time it takes to scan the folder so try and keep the folder void of everything but the movies that need renaming as the program will scan everything in the folder.

Creating corresponding thumbnails for XBMC
For those that are interested and that may be using XBMC too, after renaming the AVI files with the date and time the movie was taken, I then use FFMPEG to create thumbnails with a *.tbn extension 5 seconds into each clip.
  • Download ffmpeg and place it in your Windows\System32 folder
  • Copy this code: for %i in (*.avi) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 5 -y "%~ni.tbn" (the last speech marks are part of the code)
  • As before, hold down shift and right click to open a command prompt in the right folder location
  • Right click in the command window and paste the ffmpeg code copied above and hit Enter
Thumbnails will now be created for every movie file with the same file name. You can change how far in ffmpeg goes to create the thumbnail by modifying the -ss 5 switch and the (*.avi) switch to whatever extension your movie has. XBMC will be very happy now!

No comments:

Post a Comment