in reply to Check Directories for Files

This will find all files in the subdirectories of the Bxx dirs which you specified. This will not recurse below the Bxx dirs. File::Slurp
use strict; use warnings; use File::Slurp qw(read_dir); my $path = 'D:/DOWNLOAD/DISTRBTN/I01/B'; my @dirs = map { sprintf "$path%02d/", $_ } 1..22, 50, 60, 70, 80, 97; for my $dir (@dirs) { my @files = grep { -f "$dir/$_" } read_dir($dir); # do something with files }
If you really want all Bxx dirs, then @dirs could be simplified using glob.

Update: added grep to just get files.