Changing -datetimeoriginal yearA if (current datetimeoriginal is ne YearA)

Started by sr00t, May 08, 2018, 03:32:33 PM

Previous topic - Next topic

sr00t

Hi everyone,

I'm in the processing of correcting EXIF data on my 20 years of photo archiving. I've been reading the instructions and this forum and found most of the solutions I've sought but this one has me stumped.

In a given directory (and subdirectories) I have photos that should all be dated 2001, but some are dated 2009, or 2007, or 2014, etc.   Therefore my goal is to have Exiftool change the year of -datetimeoriginal to 2001 if it's not already set to 2001.

I have the following command that successfully identifies and lists photos that need editing;

$ exiftool -r -d "%Y" -filename -datetimeoriginal -if '($filetype eq "JPEG") and ($DateTimeOriginal ne "2001")' .
======== ./Steve_root_20180430_132017_creek_approaching_flood.jpg
File Name                       : Steve_root_20180430_132017_creek_approaching_flood.jpg
Date/Time Original              : 2018
======== ./nest/nest_derek.JPG
File Name                       : nest_derek.JPG
Date/Time Original              : 1976
    2 directories scanned
    6 files failed condition
    2 image files read


What I can't work out is how to then change the dates of these files.  If I try the date change at the end of the command I get ;
$exiftool -r -d "%Y" -filename -datetimeoriginal -if '($filetype eq "JPEG") and ($DateTimeOriginal ne "2001")' -datetimeoriginal="1961:06:01 00:00:00" .
Warning: Incomplete date/time specification in ExifIFD:DateTimeOriginal (PrintConvInv)
Ignored superfluous tag names or invalid options: -filename ...
    2 directories scanned
    6 files failed condition
    0 image files updated
    2 image files unchanged


If I try the date at the beginning I get this error;

$ exiftool '-datetimeoriginal=1961:06:01 00:00:00' -r -d "%Y" -filename -if '($filetype eq "JPEG") and ($DateTimeOriginal ne "2001")' .
Warning: Incomplete date/time specification in ExifIFD:DateTimeOriginal (PrintConvInv)
Ignored superfluous tag name or invalid option: -filename
    2 directories scanned
    6 files failed condition
    0 image files updated
    2 image files unchanged


So, I think I'm close but after lots of reading, trial and error I just can't quite grasp the solution.  Can anyone point out my error please?

Thanks
Steve


StarGeek

The -d option works both ways, when reading and writing.  So when you try to write a timestamp with '-datetimeoriginal=1961:06:01 00:00:00', the -d option converts it to just 1961.  Since that isn't a complete timestamp, that's why you get an Incomplete date/time specification error.

There are a few ways to work around it, but I'd suggest dropping the -d option and using the DateFmt function.
(${DateTimeOriginal;DateFmt("%Y")} ne "2001")

Also, instead of using $filetype eq "JPEG", you can use the -ext option to specify just jpegs, unless you have jpegs without or with an incorrect extension.

exiftool -r -filename -datetimeoriginal -ext jpg -ext jpeg -if '${DateTimeOriginal;DateFmt("%Y")} ne "2001"' -datetimeoriginal="1961:06:01 00:00:00" .

Another option would be to use the hashtag # option to disable the -d conversion
exiftool -r -d "%Y" -filename -datetimeoriginal -ext jpg -ext jpeg -if '($DateTimeOriginal ne "2001")' -datetimeoriginal#="1961:06:01 00:00:00" .
"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

sr00t