Editing image metadata with exiv2

My wife just had some maternity photos taken, and they came out wonderfully. I went to import them into Shotwell so we could upload them to her Picasa web albums (sorry, no link to her pictures)  and all the images imported in the year 2001 folder. I looked at the data and while their time stamps seemed reasonably correct, their date stamp was well over 10 years off.

I use Linux for my operating system, and a few quick good searches turned up the man page for the program exiv2. And while a man page got me there, I figured it would not hurt to provide an example (both for myself and any of you lucky people who stumble upon it).

So, first lets look at the metadata of the image.jpg:

So it says in bold up there that this image was taken on March 10th, 2001 at 03:13:05 am (it is a 24h clock).  I am not specifically worried about the time, but the date will be nice several years from now.  So we need to adjust several things, which I am going to follow in parenthesis with the cli switch the man page says we need.  What needs to adjust is the year (-Y), month (-O), day (-D), AND time (-a).  The trick with the adjustment you have to make is that it is a time shift, not a direct set.  You can not tell it the specific day, just to move the setting back or forwards, kinda like using the buttons on an alarm clock.  For all of the fields you can provide a negative or positive number, but the time field is a HH:MM:SS format with the minute and seconds being optional (but if you want to change seconds you need all 3). We want to move from March 10th, 2011 at 03:13:05am to October 15th, 2011 at about 3pmish. To do this we are going to have to adjust forward 10 years, 7 months, 5 days, and 12 hours.  So this is how the command should look:

The command does not return a visible success, which is very common for *nix applications.  But before we verify it you might be asking youself, “self, what the heck is that ad in the middle of his command?”.  Well self, that is an action, telling exiv2 that it has to do something.  This is optional if the switches you are providing imply it.  All the switches I am using do, so my use was just overly explicit.  Anyway, as I was saying, there are other ways to verify if the command ran successfully that I won’t go into here, but what better way than to check the metadata again!

Yay!  Now I just do a quick loop through all the pictures in the directory and I have an updated set.

and voila… several dozen reasonably corrected dates in the metadata of those images.  If you noticed the command was slightly different, good for you.  For the actual loop I used the shortened time adjustment I mentioned earlier and left off the ad.