How to batch convert videos keeping original creation date

Actually, this post should be titled how to edit files in a folder keeping the edit date unchanged, but in most cases it's about videos.

In fact, nowadays we record HUGE HD videos, my phone takes 200 MB / minute, if I record a short fireworks show, I get an huge 2 GB file, the same size of a full DVD movie: it's a total waste of memory, as it's shaky, it's underlighted and has awful audio.

In this cases it's possible to recompress videos with Handbrake without a visible loss of quality.

The main problem is that, when we recompress it, we lose the original date of creation/edit, and in some cases this is a big problem, especially if we want to keep them sorted chronologically, for example as a trip memory.

We can manually change the creation/edit date with utilities like this, but it's a tedious work.

What to do? I asked for help on SuperUser and John Siu wrote a PowerShell script that does exactly what I wanted!

First of all, we have to install PowerShell on our PC.

Them insert the file to be converted in a folder, and run the script SaveTime.ps1: it will save on a file the creation dates of our videos.

Now, we can convert them in batch, for example by using Handbrake batch encoder.

Once we converted them all, we can restore the original date by running OldTime.ps1, paying attention that the new files have the same name of the old ones.

If after converting, the file extension is different (for example: m4v becomes mp4), we have to change by using one of those ways:

  1. By editing the file that contains all the dates, OldTime-record.ps1 with a "find and replace" to change file extensions
  2. By renaming all the files with the DOS command *.mp4 *.m4v"