5

I have a library of about 25,000 photos (JPGs). I have been maintaining the library so that the date taken in the EXIF data reflects the actual capture date, but I keep finding exceptions where I've missed the odd photo.

Since the files are all named "YYYY xxxx" (where YYYY is the date taken, and xxxx is a description) I want to try to locate all files where the year of the date taken in the EXIF data does not match the first 4 characters of the file name.

Does anyone know of a way of doing this? I'm running Windows 7 X64

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.

  • Many thanks for this. I've downloaded ExifTool and tried the command above but I just get these two errors: "File not found: !~" and "File not found: /$DateTimeOriginal/' ??? – itm Jun 19 '15 at 10:02
  • @itm Perhaps try double quotes instead if the single quotes I used? I don't have access to Windows to try. – mattdm Jun 19 '15 at 11:36
  • Okay, confirmed in the ExifTool FAQ that Windows does indeed want double quotes here. – mattdm Jun 19 '15 at 12:10
  • That's perfect - it's now working. Thanks so much for your help. – itm Jun 19 '15 at 14:58
  • This should be able to scale up to a ridiculously large library fairly gracefully. I'm curious how long it takes on yours. – mattdm Jun 19 '15 at 15:05
0

I have used Advanced Renamer to do this. Use the Replace method and use the Image Tags as the replacement text.

  • Can this identify existing files which do not fit the scheme? – mattdm Jun 17 '15 at 14:20
  • Yes, the display shows before and after name and is color coded for changed and not changed. Nothing happens until you commit the action. – sonofcy Jun 17 '15 at 22:29
  • Thanks for this. The features look ideal but the size of my photo library makes it virtually un-usable. Simply clicking in a text box to modify a search string results in a delay of a few minutes each time. It's a shame as it looks like a really excellent tool otherwise. Once I have added my photo libary to the file list the UI is pretty much completely unresponsive :0( – itm Jun 19 '15 at 10:18

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.