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.jpg
1 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.jpg
1 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.jpg
Of 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 PIC
but this doesn't work.
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.jpgC:\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
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
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
Ah, good point. I felt I was missing something.