in reply to comparing folders

When you say "a file is the same" do you mean the file name or the file contents?

This will compare based on the file name (UNTESTED):

#!/usr/bin/perl use warnings; use strict; my $tempdir = 'c:/Temp/OneFile'; my $permdir = 'c:/Support/Files'; opendir my $TMP, $tempdir or die "Cannot opendir '$tempdir' $!"; my @onefile = grep -f "$tempdir/$_", readdir $TMP; closedir $TMP; if ( @onefile > 1 ) { die "Error: more than one file in $tempdir\n"; } if ( -f "$permdir/$onefile[0]" ) { rename "$tempdir/$onefile[0]", "$tempdir/$onefile[0]_1.txt" or die + "Cannot rename '$tempdir/$onefile[0]' to '$tempdir/$onefile[0]_1.txt +' $!"; } exit 0; __END__

Replies are listed 'Best First'.
Re^2: comparing folders
by grmshw4 (Initiate) on Jul 28, 2010 at 20:43 UTC
    Exactly what I needed it to do, thanks jwkrahn!