proc listDirRecursively {dir} { cd $dir puts "CD TO: $dir FROM [pwd]" foreach item [glob -nocomplain *] { puts "Looking at $item in [pwd]" set type [file type $item] if {$type eq "directory"} { listDirRecursively $item cd .. } elseif {$type eq "file"} { puts "FILE: $item" } } } listDirRecursively tmp