# sierrathedog04, jonathansamuel@yahoo.com, August 2001 # place this script in the target directory and # pass it the name of the source directory from the # command line. # This utility requires that the diff command works on the user's syst +em. use strict; my $sourceDir = shift || die "Please pass the name of a source directo +ry enclosed in quotes. \n"; chomp $sourceDir; $sourceDir =~ s/\/\$/\$/; unless (-d $sourceDir) { die "$sourceDir is not a valid source directory. Please pass the n +ame of a valid source directory enclosed in quotes. \n"; } opendir THISDIR, "."; my @allFiles = readdir THISDIR; closedir THISDIR; foreach (@allFiles) { if (-e "$sourceDir/$_") { print "$_ in target differs from that in source directory $sou +rceDir\n" if `diff $_ $sourceDir/$_`; } else { print "$_ found in target but not in source directory $sourceD +ir\n"; } } print "\nFinished checking target\n"; opendir SOURCEDIR, $sourceDir; my @allSourceFiles = readdir SOURCEDIR; foreach (@allSourceFiles) { unless (-e "./$_") { print "$_ found in source directory $sourceDir but not in targ +et\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compare Directories and List Changed or Missing Files
by Hofmator (Curate) on Aug 16, 2001 at 13:49 UTC | |
by sierrathedog04 (Hermit) on Aug 16, 2001 at 18:37 UTC | |
|
Modified Version 1.1
by sierrathedog04 (Hermit) on Aug 30, 2001 at 21:08 UTC | |
|
Ver. 1.2: Compare Directories and List Changed or Missing Files
by sierrathedog04 (Hermit) on Sep 19, 2001 at 21:03 UTC | |
by Anonymous Monk on Mar 05, 2012 at 20:53 UTC |