if you have Perl and can use it. Uses MD5 to check for file duplicates.
use Digest::MD5;
use File::Find;
use File::Copy;
my %seen;
my $destination = "c:/tmp";
sub getmd5 {
my $file = $_[0];
open(FH,"<",$file) or die "Cannot open file: $!\n";
binmode(FH);
my $md5 = Digest::MD5->new;
$md5->addfile(FH);
return $md5->hexdigest;
close(FH);
}
sub wanted {
if ( -f $_ && /\....$/ ){
my $file = $File::Find::name;
my $md5 = getmd5 $file;
if ( defined($seen{$md5}) ){
# duplicates
print "duplicate $file" . "=>" . $md5 ." \n";
unlink $file or die "Cannot remove $file:$!\n";
}else{
$seen{$md5} = $file;
}
}
}
my $dir = "c:/test";
# Traverse desired directory
File::Find::find({wanted => \&wanted}, $dir);
foreach my $v (values %seen){
print "\$v: $v\n";
move ("$v", "$destination" ) or warn "Cannot move file to destination:$!\n";
}
alternatively, if you want to do in batch, you can use fc command, for loop, doing some if else check etc etc..