Check that the pictures/videos in a folder has correct year and month

Started by oivindmi, June 07, 2020, 08:56:53 AM

Previous topic - Next topic

oivindmi

Hi,

I have a folder structure on my drive witch goes something like root/2011/2011-03 name of event/ "all pictures and videos from event"

I would like to verify that the pictures and videos within the folder have a year and month that matches the year and month of the folder they are in (2011-03 in this example).

I have so far gotten to this point:   exiftool  -r -d "%Y-%m" -if "$FileName !~ /^$DateTimeOriginal/" -p "$FileName"  .

The idea is that Exiftool should print me a list of the files that have issues for the specific folder. And ideally what folder they are in (missing so far).

Issues:
I have not found a way to extract the parent folder instead of the"Filename"
I am not sure if I have to extract only part of the folder name string (in this case the first 7 characters) to make it work. And not sure how to do this if it is necessary
Ideally, I would like for it to handle that events sometimes goes between two months so that it does not print the filename if it is the month before or after the folder month
Is it possible to check several tags with an OR statement and only print if no tags include the correct date (year and month)?




StarGeek

You're pretty close with your command, except you're using FileName.  You can't use Directory, because you're using a dot for the current directory, so all Directory would return is the dot.  That means you will have to use FilePath, which gives the full path name, including the file name.

To grab part of a directory name, you can use ${FilePath;$_=(split '\/',$_)[-2]}, where the number -2 is section of the path counting back from the end of the path. Since the full path includes the filename, you have to take the second from the end. A positive number would count from the beginning.

So try this:
exiftool -r -d "%Y-%m" -if "${FilePath;$_=(split '\/',$_)[-2]}!~ /^$DateTimeOriginal/" -p "$FileName" .

Quote from: oivindmi on June 07, 2020, 08:56:53 AM
I am not sure if I have to extract only part of the folder name string (in this case the first 7 characters) to make it work.

Your RegEx expression should work.  It checks to see that the beginning of the directory is the same as the DateTimeOriginal.

QuoteIdeally, I would like for it to handle that events sometimes goes between two months so that it does not print the filename if it is the month before or after the folder month

So, if the month was 2020:04, you would want to include 2020:03 and 2020:05?  That would be tough.  I can't think of an easy way to do that atm.  I think there's a way, but I can't remember off hand.  If I get some time I'll search the forums for the answer.

QuoteIs it possible to check several tags with an OR statement and only print if no tags include the correct date (year and month)?

Yes, you can use OR, AND, and NOT, as well as just about any other Perl code.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).