0

I recently discovered that the file modification timestamps on some of my photographs (stored as JPG/JPEG files) do not match the timestamps stored in their Exif data. This is odd, because I never modified any of those photographs.

I want to find other photographs for which this has happened, so I can possibly determine the cause and prevent it from happening in the future.

To help me do this, please recommend software that can compare the file modification timestamps of a batch (~50,000) of JPG files with any of the Exif timestamps stored inside them. I prefer the software use the capture time (aka original time), but it can use any of the Exif timestamp fields.

The only other requirement is that the software be compatible with Windows.

Portable, gratis, open-source software is preferred, but none are requirements.

2
  • Many file copying utilities and apps don't preserve timestamps, or provide optional arguments to preserve. – Irfan Latif Jul 29 '20 at 8:54
  • @IrfanLatif Thanks Irfan. Definitely true. The weird thing is that I intentionally choose ones that do. After I figure out which files are involved, maybe I'll have a better understanding as to what happened. I'm thinking maybe it was a particular version of an application that had a regression that has now been fixed. – RockPaperLz- Mask it or Casket Jul 29 '20 at 9:20
1

I'm a CLI lover, so would suggest exiv2 which is open-source and cross-platform. For the following simple shell script to work, all you need is exiv2 and optionally (for awk and sed) busybox binary (both portable, no installation needed). I use it on Android and Linux. On Windows you can use Cygwin or WSL (or even write a .bat script, I'm bad at that):

#!/bin/sh

DIR='/sdcard/DCIM'

find $DIR -type f -iname '*.jp*g' |
while read -r photo
do
    exif_ts=$(exiv2 -q pr "$photo" 2>/dev/null | busybox awk '/timestamp/ {print $4}' | busybox sed 's|:|-|g')
    fs_ts=$(busybox stat -c %y "$photo" | busybox awk '{print $1}')

    [ "$exif_ts" = "$fs_ts" ] || printf '%-12s%-12s%s\n' "$exif_ts" "$fs_ts" "$photo"
done

This would output all files whose timestamps differ:

...
2017-02-20  2018-12-01  /sdcard/DCIM/Camera/20170220_145017.jpg
            2017-08-15  /sdcard/DCIM/Camera/20170614171823.jpg
2016-12-30  2019-01-07  /sdcard/DCIM/Camera/FB_IMG_1483082415875.jpg
...

First column is EXIF timestamp while the second is filesystem timestamp. You can also get hour, minute and seconds in both timestamps.

3
  • That looks great. Thank you. I should have mentioned that over 50,000 photographs are involved. Any idea how to adapt it to handle that many files? Also, I'm trying to figure out how to allow your code to account for minor 1 hour differences due to daylight savings time that may cross the date boundary. – RockPaperLz- Mask it or Casket Jul 29 '20 at 9:25
  • 50000 isn't a big number for computer processor. On my Android 2500+ photos took 35 seconds. On PCs this should be far better. – Irfan Latif Jul 29 '20 at 9:46
  • Yes. I was thinking of the time spent manually reading the output. When I wrote that comment I was real tired and didn't fully process the "$exif_ts" = "$fs_ts" which minimizes that issue. – RockPaperLz- Mask it or Casket Jul 30 '20 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.