#!/usr/bin/perl # ############################################################################ # # Name: comparer.pl # Author: pete@rasterweb.net # # $Id: comparer.pl,v 1.1 2003/10/01 18:40:04 pete Exp $ # ############################################################################ ############################################################################ # use File::Find; # if running on Mac OS X and accessing Windows shares, uncomment the next line # $File::Find::dont_use_nlink = 1; $dira = '/some/original/dir'; $dirb = '/some/other/dir'; $dirapretty = 'Original Directory'; $dirbpretty = 'Other Directory'; @dirsa = ($dira); @dirsb = ($dirb); find(\&afiles, @dirsa); find(\&bfiles, @dirsb); print "\n\n"; ############################################################################ # print "Exists in $dirbpretty but missing from $dirapretty:\n\n"; foreach $f (@filesb) { if (!(exists($filesa{$f}))) { print "$f\n"; } } undef ($f); print "\n\n"; ############################################################################ # print "Exists in $dirapretty but missing from $dirbpretty:\n\n"; foreach $f (@filesa) { if (!(exists($filesb{$f}))) { print "$f\n"; } } undef ($f); print "\n\n"; ################### # subs below here # ############################################################################ ############################################################################ # sub afiles { my $file = $File::Find::name; my $dir = $File::Find::dir; $diraclean = quotemeta ($dira); $file =~ s/$diraclean//gi; # put in an array... push (@filesa, $file); # ...and in a hash $filesa{$file} = 1; } # END sub afiles ############################################################################ # sub bfiles { my $file = $File::Find::name; my $dir = $File::Find::dir; $dirbclean = quotemeta ($dirb); $file =~ s/$dirbclean//gi; # put in an array... push (@filesb, $file); # ...and in a hash $filesb{$file} = 1; } # END sub bfiles __END__ =head1 NAME comparer.pl =head1 DESCRIPTION This compares two directories, telling you what is in each, but not the other, etc... =head1 AUTHOR pete Epete@rasterweb.netE =head1 LICENSE This is free software, you may use it and distribute it under the same terms as Perl itself. =cut