my @file_list; sub files_wanted { my $text = $File::Find::name; if ( -f ) { push @file_list, $text; } } #If you set a base directory above, you will need to change $directory to $base_directory.$directory. find(\&files_wanted,$directory); #This section creates a hash of arrays of files, with the hash keys be +ing filename.ext and the file +size in #parentheses. The raw file name is the entire path including the file +name. my %files; for my $raw_file (@file_list) { my @file_parts = split(/\//,$raw_file); my $file = pop @file_parts; my $file_size = -s $raw_file; push @{$files{"$file ($file_size bytes)"}}, $raw_file; }
Why tranverse the directory tree twice (and stat each file twice) when you only have to traverse it once:
my %files; find sub { if ( -f ) { push @{ $files{ "$_ (" . ( -s _ ) . " bytes)" } }, $File::Find +::name; } }, $directory;
In reply to Re: Find duplicate files with exact same files noted
by jwkrahn
in thread Find duplicate files with exact same files noted
by Lady_Aleena
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |