Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › General › Getting a Directory Listing
Not exactly a Cloverleaf problem but I know there is a wealth of tcl knowledge in this forum.
I need to get a list of filenames in a Windows directory in tcl. I can get it to work in unix using the ls command:
set parsein “c:\lcwptest\” set wild “*” set flag “.rdy” set flist [ls $parsein$wild$flag]
This doesn
David,
You might want to check out the ‘glob’ and ‘file’ commands within Tcl.
Thanks Jim,
I stumbled upon the glob command and it looks like it will do the job.
set parsein “c:\lcwptest\” set flag “.rdy” set wild “*” set flist [glob -nocomplain -directory $parsein — $wild$flag] puts $flist
=> {c:lcwptestdave.rdy} {c:lcwptestfred.rdy}
Regards,
Dave
If I remember correctly the glob -directory returns all of the files in the directory including links, directories, and files.
It might be prudent to use the files command (with appropriate sub-commands) to select just the files that are directories if that is your interest.
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
Jim (K),
I take your point but in this case I