I'm looking for a way on macOS to filter out photos which creation date doesn't match the exif photo date. What is the best tool for doing this?
I am no expert with exiftool
but think I have got something that is 90% of what you want. I am writing it up step-by-step so that:
So the first thing is to use exiftool
to get all things related to the date:
exiftool image.jpg | grep -i date
File Modification Date/Time : 2021:01:14 10:51:38+00:00
File Access Date/Time : 2021:01:14 10:51:40+00:00
File Inode Change Date/Time : 2021:01:14 10:51:38+00:00
Modify Date : 2013:03:09 08:59:50
Date/Time Original : 2013:03:09 08:59:50
Create Date : 2013:03:09 08:59:50
That looks useful, but internally exiftool
uses Perl variables for the fields/tags, and I would like to get the variable names so I can compare them later, so I added -s
:
exiftool -s image.jpg | grep -i date
FileModifyDate : 2021:01:14 10:51:38+00:00
FileAccessDate : 2021:01:14 10:51:40+00:00
FileInodeChangeDate : 2021:01:14 10:51:38+00:00
ModifyDate : 2013:03:09 08:59:50
DateTimeOriginal : 2013:03:09 08:59:50
CreateDate : 2013:03:09 08:59:50
Ok, I think you want FileModifyDate
and DateTimeOriginal
, so let's check we can print them:
exiftool -p '$Filename, $FileModifyDate, $DateTimeOriginal' image.jpg
image.jpg, 2021:01:14 10:51:38+00:00, 2013:03:09 08:59:50
Note you MUST use single quotes on macOS/Linux else the bash
shell tries to expand the variable and it expands to nothing - unless you happen to have a bash
variable called DateTimeOriginal
. I guess you would have to use double quotes on Windows because it doesn't generally understand single quotes.
That's good, but you aren't interested in the hours, minutes and seconds, so we can change the way exiftool
considers dates to only look at the year, month and day with -d
:
exiftool -d %F -p '$Filename, $FileModifyDate, $DateTimeOriginal' image.jpg
image.jpg, 2021-01-14, 2013-03-09
Now we want to check whether they are the same (for all JPEG files) with an if
statement and only print "unhappy" files:
exiftool -d %F -if '$FileModifyDate !~ $DateTimeOriginal' -p '$FileName' *.jpg
image.jpg
iphone.jpg
2 files failed condition
If you are vaguely uneasy with Perl string comparisons like that, you could do the tests and printing with awk
like this:
exiftool -d %F -p '$Filename, $FileModifyDate, $DateTimeOriginal' *.jpg | awk -F, '$2 != $3{print $1}'
Note the above only executes a single exiftool
process. I think you probably want to avoid running a whole new process for exiftool
with every file, so do NOT do this:
find ... -iname "*.jpg" -exec exiftool ... {} \;
I think you can recurse into subdirectories with -r
but I haven't tried that.
By the way, on macOS you can install exiftool
most simply with homebrew:
brew install exiftool
Keywords: exiftool, creation date. modification date, EXIF date, matching, non-matching, photo, photos, prime.