Adjusting timestamps on JPG and regular files

Having returned from a holiday recently, I found out that my camera was set to a different timezone. Oh dear, now all the (EXIF) timestamps are wrong! Luckily there’s a tool called ‘exiv2’ on Debian that can easily fix this (among many other functions):

First, let’s adjust all timestamps and deduct 1 hour from them:

exiv2 -a -1 *.jpg

If you need to add time, specify a positive number of hours after the ‘-a’ parameter

Next, we want to adjust the file timestamp to match the new EXIF date/time:

exiv2 -T *.jpg

Now we want to adjust the timestamps for any .MOV files as well. Since there is no EXIF tag, I will just adjust the file timestamps directly with ‘touch’:

for i in *.MOV; do touch -r $i -d '-3600 seconds' $i; done

So what does this last line do? For each MOV file, it takes the current timestamp (-r) as a reference and deducts 3600 seconds (1 hour) from the timestamp. Wrap this in a loop to process all files and you’re done! Quick and easy fix and now the timestamps will line up again with my other devices :)