Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems creating a list of directories on windows 1

Status
Not open for further replies.

Ati2ude

Programmer
Dec 11, 2001
79
US
Hi all,

I have tried this several ways and can not seem to get what I am looking for. What I want to do is create a list of sub directories under a specified directory. I will then iterate thru each of them, looking for specific files.

Here is what I have tried.
set processdir [concat $rootdir/processes]
set process_list [exec ls $processdir]
foreach process $process_list {
echo "******************************************"
echo $process
echo "******************************************"

}

TIA for any help you can lend.

Ati2ude
 
Will the glob command give me a listing of sub-directories only? I need the sub-dirs first.


Ati2ude
 
Never mind I see what you are saying. Let me play with this a few.

Thanks for the quick reply.

Ati2ude
 
You can also use cmd dir...

set your_var [exec cmd /C dir /B "$dir"]
 
To list all subirs from dir, indenting at each level:

Code:
  proc subdirs {dir {level 0}} \
  {
    puts [string repeat " " $level]$dir
    incr level
    foreach subdir [glob -dir $dir -type d -nocomplain *] \
    {
      subdirs $subdir $level
    }
  }
  
  subdirs /

More on glob at
HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top