map {mkdir $_; chdir $_;} @folders; my $output="z.txt"; open (my $fh,">",$output) or die "Cannot open file '$dirname/$output'.\n";