Hello,
I have some pictures that had their DateTimeOriginal corrupted or erased.
Hopefully, their names are in this form: 2012-07-23_10.08.46.jpg.
How to restore the EXIF original date using the filename?
Thanks,
Alban
Hi Alban,
You can use this command:
exiftool "-datetimeoriginal<filename" FILE
were FILE is one or more file names or directory names.
- Phil
Thanks Phil,
Unfortunately I get the following error message:
Warning: Invalid EXIF text encoding - 2012-07-25 21.51.06.jpg
Error: Error reading OtherImageStart data in ExifIFD - 2012-07-25 21.51.06.jpg
What does it mean?
Alban
Hi Alban,
It means that your metadata is corrupted. See FAQ 20 (https://exiftool.org/faq.html#Q20) for details about how to fix this.
- Phil
The answer was in the FAQ (as usual :o )
This
exiftool -all= -tagsfromfile @ -all:all -unsafe 2012-07-25\ 21.51.06.jpg
corrected the file!
Then your command set correctly the date.
Thanks 1000000 times for your software
Alban
Hi
I am in a similar situation. I have a file named 09-03-06.jpg. It lacks any exif data whatsoever. So I tried adding the datetimeoriginal to it with the following command in a .bat file placed in the image containing folder itself:
exiftool -if "not defined $DateTimeOriginal" "-DateTimeOriginal<FileName" "09-03-06.jpg"
But I get the error:
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv)
Please Help!
The year needs 4 digits (YYYY), and you also need to specify a time. Plus it looks like you forgot a $ in front of Filename.
With a bit of advanced exiftool magic, you may, however be able to pull it off:
exiftool -if "not defined $DateTimeOriginal" "-DateTimeOriginal<${FileName;s/^/20/;s/$/ 00:00:00}" "09-03-06.jpg"
This prefixes the filename with 20 for the century and also adds 00:00:00 for the time.
Just two minor points:
1) "-DateTimeOriginal<FileName" is correct, and is the simple form used to copy a tag without modification.
2) Adding the "20" to the start, and the time to the end could be done a bit more simply (without the advanced formatting feature), like this:
"-DateTimeOriginal<20${FileName} 00:00:00"
- Phil
BTW, Hayo: thanks for all your help on the forum
Quote from: Phil Harvey on August 15, 2014, 06:55:06 PM
Just two minor points:
1) "-DateTimeOriginal<FileName" is correct, and is the simple form used to copy a tag without modification.
2) Adding the "20" to the start, and the time to the end could be done a bit more simply (without the advanced formatting feature), like this:
"-DateTimeOriginal<20${FileName} 00:00:00"
Ah, true of course, should've thought about that.
Quote from: Phil Harvey on August 15, 2014, 06:55:06 PM
BTW, Hayo: thanks for all your help on the forum
You're more than welcome; it also helps me learn some new stuff so we all benefit :)