use warnings; use strict; use File::Find; my $directory = '/mnt/music/very-good'; find (\&wanted, $directory); my %path_file; sub wanted { my $path = $File::Find::dir; my $filename = $File::Find::name; $hash{$path} = $filename; } my %count; while (my ($key , $value) = each(%path_file)) { $count{$key} +=1; }