[Originally posted by exiftool on 2009-11-25 16:32:17-08]To just find out which images have the wrong date,
you use this command assuming that the images are all
in subdirectories named by year in the current directory:
exiftool -r -if "$datetimeoriginal !~ /^$directory" -datetimeoriginal *
(use single instead of double if you are on Mac or Linux)
To fix all dates automatically is somewhat trickier, but
could be done very effectively with this config file:
%Image::ExifTool::UserDefined = (
# Composite tags are added to the Composite table:
'Image::ExifTool::Composite' => {
FixDateTimeOriginal => {
Require => {
0 => 'DateTimeOriginal',
1 => 'Directory',
},
ValueConv => q{
$val[1] =~ /((20|19)\d{2})/ or warn("No DateTimeOriginal"), return undef;
my $year = $1;
$val[0] =~ /$year/ and warn("Year is OK"), return undef;
$val[0] =~ s/((20|19)\d{2})/$year/ or
warn("Bad date format"), return undef;
return $val[0];
},
},
},
);
1; #end
And this command:
exiftool "-datetimeoriginal<fixdatetimeoriginal" -r DIR
However, this would only fix DateTimeOriginal, and you likely want
to also fix CreateDate and ModifyDate. You can do all 3 at the same
time with the necessary definitions and command-line arguments.
- Phil