Change filemodifydate to datetimeoriginal if it's not the same

Started by harryyhl, November 23, 2016, 06:58:16 AM

Previous topic - Next topic

harryyhl

Hi Phil, thanks so much for developing ExifTool it's wonderful.

I want to change the filemodifydate of my jpg files to datetimeoriginal if it's not the same, here's the command:

exiftool '-filemodifydate<datetimeoriginal' -r -if '(not $datetimeoriginal eq $filemodifydate) and ($filetype eq "JPEG")' .

However it changed ALL jpg files even if both dates are identical, as I found out the reason is that filemodifydate has timezone while datetimeoriginal has not:

exiftool '-filemodifydate' '-datetimeoriginal' .
======== ./DSC00216.JPG
File Modification Date/Time     : 2010:10:18 13:01:58+08:00
Date/Time Original                 : 2010:10:18 13:01:58
======== ./DSC00214.JPG
File Modification Date/Time     : 2010:10:17 16:37:01+08:00
Date/Time Original                 : 2010:10:17 16:37:01

So how can I modify the syntax so that it can compare the 2 dates correctly?
Many thanks

Phil Harvey

Try this:

exiftool '-filemodifydate<datetimeoriginal' -r -if '$datetimeoriginal ne substr($filemodifydate,0,19)' -ext jpg .

(here I have used the -ext option to save on having to read non-jpg files)

- 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 ($).