I only like to set the year on my images without changing the month, day or time.
A linux bash command would be nice.
Depending upon exactly what you are doing, exiftool can do this in batch without a script.
If your files have the year offset by the same amount, then you can use the time shift feature to shift the time forward/backwards (see the -TAG[+-^]=[VALUE]
option and ExifTool Date/Time Shift Module)
For example, to shift the year back by two years, you would use a command like
exiftool -AllDates-="2:0:0 0" /path/to/files/
And to reverse it
exiftool -AllDates+="2:0:0 0" /path/to/files/
AllDates
is an exiftool shortcut that will edit the three major EXIF tags, DateTimeOriginal
, DateTimeDigitized
(called CreateDate
by exiftool), and DateTime
(called ModifyDate
by exiftool). The 2:0:0 0
represents the Year Month Day and Hour to shift by, and Minutes and Seconds can be added after the hour. With a single number, exiftool defaults to shifting the Hour, so to shift the Year, Month, or Day, you have to put a space before the hour.
If you want to batch replace a specific year with an entirely different one without affecting any other file, it becomes a bit more complicated. Instead of shifting, the easiest option would be to use the -api Filter
option to apply a RegEx to the values and then the -TagsFromFile
option to copy the new values back into the file
For example, to change any file with a year of 2026 into 2024 without affecting the 2023/2022/etc files, you would use a command like
exiftool -api "Filter=s/2026/2024/" -TagsFromFile @ -AllDates /path/to/files/
These commands creates backup files. Add -overwrite_original
to suppress the creation of backup files. Add -r
to recurse into subdirectories.