Posted to tcl by cgm at Mon Jan 22 09:20:05 GMT 2024view raw

  1. proc get_filesnames {} {
  2. set namelist {}
  3. add_filenames . [file_pattern] namelist
  4. return $namelist
  5. }
  6.  
  7. proc add_filenames {dir fpat listVar} {
  8. upvar $listVar namelist
  9.  
  10. foreach f [lsort [glob -directory $dir -nocomplain -type {f r} -- $fpat]] {
  11. lappend namelist $f
  12. }
  13.  
  14. foreach d [lsort [glob -directory $dir -nocomplain -type {d r} -- *]] {
  15. add_filenames $d $fpat namelist
  16. }
  17. }