Putting date and time in filenames

My camcorder generates digital video-files named 00001.MTS, 00002.MTS, and so on. When I connect the camera to a computer using USB, I can move the files to harddisk as is. Unfortunately, when I process the video into other formats (avi, mp4 etc.), the original time-stamp gets lost, so there is no way to (later) see when they were filmed (or stored on the camcorder to be exact). This isn’t useful.
I’ve been looking for a method to flawlessly rename (folders full of) many camcorder files with their original date and time inserted in the name, so I can easily find what I’m looking for, and don’t have to lose time over it as I was used to.

After doing a lot of experimenting using the “for” command for Windows .bat files, and with help of some co-wizzards, I came up with this batch file. It uses the Windows Script Host and Visual Basic script, and works in all Windows 32 bit and x64 Operating Systems (yes, even Vista).

How to use it and What does it do? Easy:

– Unpack datetime_renamer.bat from this zip-file
– Put it in the folder where your camcorder-files are (the files you want to give a more logical name).
– If you double-click the bat file, this is what the script will do:

00020.MTS
00021.MTS

will be renamed to (for example):

20080715_22h50m24s_00020.MTS
20080715_22h53m12s_00021.MTS

You’ll see that it takes the DateLastModified from the files, puts that in front of the original filenames, et voila: Problem solved! Be careful not to run the batch file twice, because it will simply continue renaming, so you’ll end up with files like 20080715_22h50m24s_20080715_22h50m24s_00020.MTS :-D

Makes you wonder why those camcorders and digital cameras don’t save files this way by default. I mean, it solves problems of not having unique filenames when batteries die and you lose sequential file-numbering etc. This again makes it quite obvious I should become filthy rich putting this idea out there in the first place. ;-) Special thanks go out to Tom Lavedas and foxidrive in alt.msdos.batch.nt for their clues.

Leave a Reply