push (@total, $fileslistcount); $total = @total;) #### chdir($desktop_dir) or mail ($to = $dllist, $from = $dllist, $subject= "ERROR $desktop_dir $!", $body ="ERROR $desktop_dir $!" ); (@listofdir) = glob "*txt"; foreach my $file (@listofdir){ chdir($desktop_dir) or mail ($to = $dllist, $from = $dllist, $subject= "ERROR $desktop_dir $!", $body ="ERROR $desktop_dir $!" ); open(my $fh, '<:encoding(UTF-8)', $file)or mail ($to = $dllist, $from = $dllist, $subject= "error opening $file $!", $body ="ERROR opening to $file $!" ); open FILE, ">> $mastercount" or mail ($to = $dllist, $from = $dllist, $subject= "ERROR opening $mastercount", $body ="ERROR opening $mastercount" ); while (my $row = <$fh>) {#2 chomp $row; foreach ($row) { chdir ($row)or mail ($to = $dllist, $from = $dllist, $subject= "error opening $row", $body ="ERROR opening to $row" ); if ( -e "Thumbs.db") { unlink ("Thumbs.db") or print "thumbs.db $!\n"; }; (@fileslist) = glob "*{jpg,gif,psd,png,tif,tiff}"; my $fileslistcount = @fileslist; push (@total, $fileslistcount); $total = @total; if ($fileslistcount > 0){ print "total files in $row:$fileslistcount\n"; } else { # print "not enought files to count\n"; } } } print "total files in $total\n"; }; close FILE;