How can I find JPEGs where the EXIF capture year doesn’t match the year at the start of the filename?
Asked 6/16/2015
4 views
2 answers
0
I have about 25,000 JPG files on Windows 7 x64. My filenames begin with the capture year, for example YYYY description, and I’ve been trying to keep the EXIF capture date consistent with that. However, I suspect some files still have the wrong EXIF date.
I’d like a way to identify all JPEGs where the year in the EXIF DateTimeOriginal field does not match the first four characters of the filename. Is there a tool or command that can compare the EXIF capture year against the filename and list the mismatches?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
11y ago
2 Answers
12
ExifTool is a cross-platform tool which will work from the Windows command line. It is very powerful, with a perl-based syntax allowing comparison of various metadata. In a directory full of JPEG files, this command will print a list of all files where the beginning of the filename does not match the year from the date-taken EXIF value:
exiftool -d "%Y" -if "$FileName !~ /^$DateTimeOriginal/" -p "$FileName" *.jpg
Note the double quotes since you are on Windows. On Mac or Linux, use single quotes:
exiftool -d '%Y' -if '$FileName !~ /^$DateTimeOriginal/' -p '$FileName' *.jpg
This will also print something like "1600 files failed condition" — here, "failed" means that they are named correctly, since the "condition" given is not matching, which is indicated by the !~ operator. Change that to =~ if you want it to print only the files which do match. (The ^ indicates the beginning of the file — the syntax is that of perl regular expressions.)
The part -d '%Y' sets the date format to be just the year. You can change that to match your naming convention. For example, if your files are supposed to start with a four digit year, two digit month, and two digit day, separated by a dash, use -d '%Y-%m-%d'.
If you have multiple folders, replace *.jpg at the end of the line with -r ., which will make ExifTool run recursively in every one. (The . is assuming you want to start in the current directory — change the . to a pathname if you want to run it somewhere else). Also in that case you probably want -p '$Directory/$FileName instead of just FileName alone.
If you want to dig into it, ExifTool can even rename the files conditionally, so you could extend the above to fix your problem files, rather than just identifying them.
You could also use ExifTool to copy the description portion of your filename into the file's internal metadata, perhaps setting it as the XMP Title.
Originally by user1943. Source · Licensed CC BY-SA 4.0
user1943
11y ago
0
Generated from our catalog & community — verify before relying on it.
Yes. ExifTool can do this from the Windows command line by comparing the filename prefix to the EXIF DateTimeOriginal year.
Use this in the folder containing the JPGs:
exiftool -d "%Y" -if "$FileName !~ /^$DateTimeOriginal/" -p "$FileName" *.jpg
What it does:
-d "%Y"formatsDateTimeOriginalas a 4-digit year-ifkeeps only files where the filename does not start with that year-p "$FileName"prints the filenames that mismatch
On Windows, use double quotes as shown.
Another option mentioned is Advanced Renamer, using a Replace method with Image Tags, but ExifTool is the more direct solution for reporting mismatches.
Make sure your files actually contain DateTimeOriginal; images without that tag may need separate handling.
Recommended products
UniqueBot
AI11y ago
Your Answer
Related Questions
How can I set EXIF date tags from the filename using ExifTool?
How can I set photo capture dates from filenames before uploading to Google Photos?
How can I rename photo files using the EXIF capture date?
How can I batch rename photos by date and check for out-of-order timestamps?
How can I use ExifTool to copy only photos rated 4+ into one export folder and ignore dotfiles?