To process a large number of dirs and subdirs with subdirs... one could try threads to see if this speed up things.
How could this first shot be improved?
Try example e.g. with
tclkitsh xxx.tcl c:/windows
lappend auto_path ./ package require Thread set tp [tpool::create -minworkers 10 -maxworkers 200] foreach dir [glob -nocomplain -type d -dir [lindex $argv 0] -- *] { lappend res $dir lappend threadList [tpool::post $tp [format { if {![catch {glob -nocomplain -type d -dir %s -- *} res]} { return $res } } $dir]] } while {[llength $threadList]} { set completedThreads [tpool::wait $tp $threadList threadList] foreach t $completedThreads { set dirs [tpool::get $tp $t] if {[llength $dirs]} { lappend res {*}$dirs foreach dir $dirs { lappend threadList [tpool::post $tp [format { if {![catch {glob -nocomplain -type d -dir %s -- *} res]} { return $res } } $dir]] } } } } tpool::release $tp puts [join [lsort $res] \n]