Pity you aren't going the other way (copying information from files in a
single directory to files in a hierarchy), because you could do that with:
exiftool -r -tagsfromfile d:\dirx\%f.jpg -ext jpg c:\
but that won't work for what you want to do.
In your case you will have to use a script to automate what you want to do.
Using the following command:
script_name C:\ D:\dirx
This perl script should do what you want:
#!/usr/bin/perl -w
use strict;
my $src = shift;
my $dst = shift || die "Must specify source and destination directory\n";
opendir(DIR, $src) or die "Error opening directory $src\n";
my @files = readdir(DIR);
closedir(DIR);
-d $dst or die "$dst is not a directory\n";
my ($file, $jpg);
foreach $file (@files) {
next if $file =~ /^\./ or not -d "$src/$file";
print "==== Directory $src/$file:\n";
opendir(DIR, "$src/$file") or die "Error opening $src/$file\n";
my @jpgs = readdir(DIR);
closedir(DIR);
foreach $jpg (@jpgs) {
next unless $jpg =~ /\.jpg/i;
my $srcname = "$src/$file/$jpg";
my $dstname = "$dst/$jpg";
print "---- Source file: $srcname\n";
-e $dstname or warn("Warning: $dstname doesn't exist\n"), next;
print `exiftool -tagsfromfile "$srcname" "$dstname"`;
}
}
# end