foreach path {tmp tmp/tmp1 tmp/tmp2 tmp/tmp3} { file mkdir $path foreach nm {fileA.dat fileB.txt fileC.txt} \ contents [list 12345 1234567 $path] { set of [open $path/$nm w] puts $of $contents close $of } }