Ubuntu – Change the date and time (or any other EXIF image meta-data)

There is a very flexible and easy Linux tool that helps you change the EXIF meta-data of images. It allows you to change individual files or whole bunch of them with one command. You can also put different rules about what files and how you want to change them if you need to.

The program is called exiftool. So let’s install it first.

In terminal execute:

sudo apt-get install libimage-exiftool-perl

Now you are ready to start changing the meta-data of the images.

For example, if I wanted to change all the dates and times (DateTimeOriginal, CreateDate and ModifyDate) of the IMG_01.jpg file to the 8th of September 2011 at 6:00:00 PM I would do:

exiftool -AllDates='2011:09:08 18:00:00' -overwrite_original IMG_01.jpg

If I wanted to change the dates on all the files in the “images” directory, I would do:

exiftool -AllDates='2011:09:08 18:00:00' -overwrite_original images

The “-overwrite_original” option is necessary if you want to change the meta-data of the original images. If you omit that option, then exiftool will back-up the originals by making a copy of them and adding “_original” to the end of the file names.

If you want to change the dates to all the files in the “images” directory that were taken by a Nikon camera (and not touch the rest) I would do:

exiftool -AllDates='2011:09:08 18:00:00' -if '$make eq "Nikon"' -overwrite_original images

As far as changing dates and times, there is another option of exiftool that lets you do time calculation.

For example, the other day I found out that my camera’s time was correct but the date was ahead by 30 days. That meant that all the photos I had taken lately had dates that were off by exactly 30 days. If I were to use the above examples I could set the dates individually (which would be a long and tedious process) or set all the images to the same date and time (which would be wrong). In this case I used the date calculating option and just executed:

exiftool -AllDates-=720:00 -overwrite_original images

That command subtracts 720 hours (30 days) off the dates of each image file in the images directory. Now every image has the exact date and time it was taken.

I have only scratched the surface of what this tool is capable of. For more information look at the man pages of the exiftool command.



2 Replies to “Ubuntu – Change the date and time (or any other EXIF image meta-data)”

  1. To subtract 30 days, you could have also done this:

    exiftool -alldates-=”30 0″ -overwrite_original imgaes

    this saves doing the math to convert to hours. (Also, the “:00” was unnecessary in your example because hours is assumed if only one number is provided.)

Leave a Reply

Your email address will not be published. Required fields are marked *