Fix modified date from file-name

The other day, while I was working on my star trail photography album and vacation pictures, I accidently updated all files’ modification time incorrectly. Whoops! For some reason, the “undo” was not a choice. And without proper chronological sequence, there was no way, my post image processing software was going to give me the exact star trail picture. After you chase weather for weeks, and work-out details like a perfect clear sky, no air planes and spend almost entire night in winter taking really long exposure pictures, this not even the last thing you want to happen. What a mess!

Here are 3 sample file names which I had to deal with:

  • 20160530_134327.jpg
  • 20160530_134417_Pano.jpg
  • 20160530_163722(1).jpg

Soon I noticed, that the file name itself has a date stamp. Voila, I could restore them, but how? I had screwed up almost more than 394 pictures! The way I saw it, I had 2 options:

  • Either, by using some date utility software or uploading all pictures to Google Drive or OneDrive which also let me fix the date time stamp – these would let me fix one picture at a time
  • Or, I could do something about it

The first alternative, as a computer scientist, was very inefficient time & bandwidth wise, not to mention very boring. The latter, was to write a program, using my repertoire of C# and .NET. The entire code was less than 20 lines and took less than 5 minutes to get me going … also I can tweak and reuse this code in future if I need to!

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s