find sub { # first filter out your directories if (-d && $_ !~ / my_target_dirs_regex / ) { $File::Find::prune = 1; return; } # if you make it to here, you are in your target subdir # now do your ImageMagick processing and mkdir # it has to check each file for a .png ending if (-f && $_ =~ / (.*)\.png$ / ) { # do mkdir stuf # do ImageMagick stuff } # or you could just push the files into an array for later processing # push @goners, $File::Find::name; }, @ARGV;