Fixing Dates in Image EXIF Tag Data from Linux
published 2009-06-21 · refreshed 2026-10-20 · tested on Ubuntu 26.04 · exiftool 13.50 · jhead 3.08 · tags: cli, exif, graphics, jpeg, linux, ubuntu
The camera that lost track of time is still with us, now as a phone with the wrong time zone or a scanner that stamps today’s date on 1990s prints. jhead, the 2009 answer, is still in the repositories and still fine for JPEGs. The tool to learn, though, is exiftool: it handles RAW, HEIC, PNG and video as well as JPEG, it can shift dates instead of overwriting them, and it can copy a date between the EXIF tags and the file system in either direction.
sudo apt install libimage-exiftool-perl jhead
Read the dates
exiftool -s -AllDates image.jpg
DateTimeOriginal : 2009:06:21 10:00:00
CreateDate : 2009:06:21 10:00:00
ModifyDate : 2009:06:21 10:00:00
-AllDates is shorthand for the three EXIF date tags; -s prints the tag names instead of descriptions. Photo managers sort by DateTimeOriginal.
Shift by an offset (the camera was a year behind)
This is the case the 2009 text handled badly, because jhead -ts set every photo to the same timestamp. exiftool adds or subtracts a delta and keeps the relative order:
exiftool -overwrite_original "-AllDates+=1:0:0 0:0:0" image.jpg
The delta is Y:M:D h:m:s. Subtract two and a half hours for a wrong time zone:
exiftool -overwrite_original "-AllDates-=0:0:0 2:30:0" image.jpg
Without -overwrite_original, exiftool keeps a copy of each file as image.jpg_original, which is the safe default while you are still finding the right offset.
Set one date explicitly
exiftool -overwrite_original -DateTimeOriginal="2003:01:01 00:00:00" -CreateDate="2003:01:01 00:00:00" image.jpg
File time from EXIF, or EXIF from file time
Two tags that often disagree: the EXIF date (what the camera said) and the file’s modification time (what the copy said). Make the file system match the photo:
exiftool -overwrite_original "-FileModifyDate<DateTimeOriginal" image.jpg
Or, for scans and screenshots with no EXIF date at all, write the file time into the tag so albums sort properly:
exiftool -overwrite_original "-DateTimeOriginal<FileModifyDate" image.jpg
A whole directory
-r recurses, -P preserves file modification times, and a directory argument processes every image in it:
exiftool -r -P -overwrite_original "-AllDates+=0:0:1 0:0:0" ~/Pictures/2003-trip/
Mixed folders are fine: a warning like Can't shift from year 0000 when shifting CreateDate - ./clip.mp4 just means that file had no such date to shift, and it is left alone.
jhead, for the record
Still installed with sudo apt install jhead, still JPEG-only, and the 2009 options still work:
jhead image.jpg
jhead -ts2003:01:01-00:00:00 image.jpg
jhead -da2004:01:01-2003:01:01 image.jpg
jhead -ft image.jpg
-ts sets the timestamp outright, -da shifts dates by the difference between two dates (here, one year forward), -ft sets the file’s modification time from the EXIF date. For anything that is not a JPEG, or for a shift expressed in hours, use exiftool.
AS PUBLISHED, 2009
I recently needed to organize a large number of old digital photos that had the wrong date embedded in their EXIF tag data. The camera I used many years ago would often lose track of time and would sometimes be set to the wrong year. Applications I now use to organize photos read this data and made my albums difficult to navigate. I came across a Linux command line utility called jhead that allows you to modify this information to whatever you wish, and its easy to use in scripts as well. Installing was easy, because it’s currently in most repositories, including Ubuntu’s.
To read existing EXIF tag data, simply run jhead against an image without any options. As you can see from the example below, my date is set to the year 2022.
jhead image.jpg
File name : image.jpg
File size : 159390 bytes
File date : 2004:01:12 07:35:23
Camera make : Samsung
Camera model : Digimax 200
Date/Time : 2022:02:12 04:04:17
Resolution : 800 x 600
Flash used : Yes
Exposure time: 0.045 s (1/22)
Aperture : f/2.8
To clear all EXIF data from the file, use the -de option. Then recreate the EXIF fields with the -mkexif option, and check the data again. Notice the new Date/Time is set to the timestamp on the file.
jhead -de image.jpg
Modified: image.jpg
jhead -mkexif image.jpg
Modified: image.jpg
jhead image.jpg
File name : image.jpg
File size : 147751 bytes
File date : 2004:01:12 07:35:23
Date/Time : 2004:01:12 07:35:23
Resolution : 800 x 600
To change the entire timestamp manually, use the -ts option. Notice, there is no space between the -ts and the option. I could not trust the month and day, so I simply chaged the date to midnight on January 1, 2003.
jhead -ts2003:01:01-00:00:00 image.jpg
Modified: image.jpg
jhead image.jpg
File name : image.jpg
File size : 147751 bytes
File date : 2004:01:12 07:35:23
Date/Time : 2003:01:01 00:00:00
Resolution : 800 x 600
For many more options, check out the man page or visit the jhead site for more info.