Invalid DateTimeOriginal tag

Started by Bimbam, March 02, 2023, 07:24:32 AM

Previous topic - Next topic

Bimbam

I didn't want to open a new topic, because I'm also struggling with something like this, just with a little twist..
**************************************
I got stuck. I tried something like this. If 'DateTimeOriginal' is missing, enter the date from the 'FileModifyData' field.
exiftool -time:all -g1 -a -s PIC_20120202_072908-P020212_07.29.jpg ---- System ----
FileModifyDate                  : 2012:02:02 07:29:08+01:00
FileAccessDate                  : 2023:03:02 12:02:21+01:00
FileInodeChangeDate            : 2023:03:02 12:01:35+01:00
---- IFD0 ----
ModifyDate                      : 2
---- ExifIFD ----
DateTimeOriginal                : 2
CreateDate                      : 2

I don't even understand why/how the dates became numbers. That's what I tried anyway.
exiftool -if 'not $DateTimeOriginal' '-DateTimeOriginal<FileModifyDate' PIC_20120202_072908-P020212_07.29.jpg1 files failed condition

Then with this, but since it's the same syntax, why would it work?
exiftool -if 'not $DateTimeOriginal' '-alldates<FileModifyDate' PIC_20120202_072908-P020212_07.29.jpg1 files failed condition

However, interestingly, as soon as I removed the condition from it, it immediately updated the dates.
exiftool '-alldates<FileModifyDate' PIC_20120202_072908-P020212_07.29.jpgOf course, with a warning:
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - PIC_20120202_072908-P020212_07.29.jpg
    1 image files updated

And the condition would be needed, something like this in a bash pattern:
if 'not $DateTimeOriginal' then
    overwrite all dates from 'FileModifyDate'
fi
exiftool -if 'not $DateTimeOriginal' '-alldates<FileModifyDate' -execute '-filename<${model}/${datetimeoriginal}' -common_args -d '%Y/%Y-%m/PIC_%Y%m%d_%H%M%S%%-c.%%le' -overwrite_original PICbut this doesn't work.

StarGeek

Quote from: Bimbam on March 02, 2023, 07:24:32 AMI didn't want to open a new topic

It is preferable to open a new topic, especially since this is a completely different situation.  I'll split this off into a separate topic.

QuoteIf 'DateTimeOriginal' is missing, enter the date from the 'FileModifyData' field.
exiftool -time:all -g1 -a -s PIC_20120202_072908-P020212_07.29.jpg
---- System ----
FileModifyDate                  : 2012:02:02 07:29:08+01:00
FileAccessDate                  : 2023:03:02 12:02:21+01:00
FileInodeChangeDate            : 2023:03:02 12:01:35+01:00
---- IFD0 ----
ModifyDate                      : 2
---- ExifIFD ----
DateTimeOriginal                : 2
CreateDate                      : 2

I don't even understand why/how the dates became numbers. That's what I tried anyway.
exiftool -if 'not $DateTimeOriginal' '-DateTimeOriginal<FileModifyDate' PIC_20120202_072908-P020212_07.29.jpg
1 files failed condition

This fails simply because DateTimeOriginal exists.  It has very Invalid value of 2, but it does exist.

Try this.  It checks to make sure that DateTimeOriginal is the correct length of 19 characters.
exiftool -if 'length($DateTimeOriginal)<19' '-alldates<FileModifyDate' PIC_20120202_072908-P020212_07.29.jpg

C:\Programs\My_Stuff>exiftool -time:all -G1 -a -s y:\!temp\Test3.jpg y:\!temp\Test4.jpg
======== y:/!temp/Test3.jpg
[System]        FileModifyDate                  : 2023:03:02 12:00:00-08:00
[System]        FileAccessDate                  : 2023:03:02 08:24:10-08:00
[System]        FileCreateDate                  : 2023:03:02 12:00:00-08:00
[IFD0]          ModifyDate                      : 2
[ExifIFD]      DateTimeOriginal                : 2
[ExifIFD]      CreateDate                      : 2
======== y:/!temp/Test4.jpg
[System]        FileModifyDate                  : 2023:03:02 12:00:00-08:00
[System]        FileAccessDate                  : 2023:03:02 08:24:10-08:00
[System]        FileCreateDate                  : 2023:03:02 12:00:00-08:00
[IFD0]          ModifyDate                      : 2023:03:02 12:00:00
[ExifIFD]      DateTimeOriginal                : 2023:03:02 12:00:00
[ExifIFD]      CreateDate                      : 2023:03:02 12:00:00
    2 image files read

C:\Programs\My_Stuff>exiftool -P -overwrite_original -if "length($DateTimeOriginal)<19" "-alldates<FileModifyDate" y:\!temp\Test3.jpg y:\!temp\Test4.jpg
    1 files failed condition
    1 image files updated

C:\Programs\My_Stuff>exiftool -time:all -G1 -a -s y:\!temp\Test3.jpg y:\!temp\Test4.jpg
======== y:/!temp/Test3.jpg
[System]        FileModifyDate                  : 2023:03:02 12:00:00-08:00
[System]        FileAccessDate                  : 2023:03:02 08:24:47-08:00
[System]        FileCreateDate                  : 2023:03:02 12:00:00-08:00
[IFD0]          ModifyDate                      : 2023:03:02 12:00:00
[ExifIFD]      DateTimeOriginal                : 2023:03:02 12:00:00
[ExifIFD]      CreateDate                      : 2023:03:02 12:00:00
======== y:/!temp/Test4.jpg
[System]        FileModifyDate                  : 2023:03:02 12:00:00-08:00
[System]        FileAccessDate                  : 2023:03:02 08:24:47-08:00
[System]        FileCreateDate                  : 2023:03:02 12:00:00-08:00
[IFD0]          ModifyDate                      : 2023:03:02 12:00:00
[ExifIFD]      DateTimeOriginal                : 2023:03:02 12:00:00
[ExifIFD]      CreateDate                      : 2023:03:02 12:00:00
    2 image files read
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Bimbam

QuoteIt is preferable to open a new topic, especially since this is a completely different situation.  I'll split this off into a separate topic.
Ok. I understood. This EXIFTOOL is awesome. ;D

Phil Harvey

I would suggest this condition:

-if 'not $DateTimeOriginal or length($DateTimeOriginal)<19'

To also write the file if DateTimeOriginal doesn't exist.

And be sure to use double quotes instead of single if you are running in a Windows CMD shell.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Ah, good point.  I felt I was missing something.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype