So I need to loop through a tree of directories, currently I can print off all the files in a directory, but once that is done I need to be able to go into the subfolders of the starting directory and so on. My Program prints off the files and the folders as a start, but I need to check each one to make sure it is a directory and then enter it. Could someone provide some guidance on this?
migrated from stackoverflow.com Sep 29 '11 at 10:36
|
|
|||
|
|
|
From comments entered to some of the responses I am guessing you want to run some script in each of the directory. In that case one of the possible ways is to use
For example, in the current dir there is a script
To the |
|||
|
|
|
Use the
|
|||
|
|
Pseudo code:
|
|||
|
this finds all subdirectories |
|||||
|
|
Based on some of the comments, I'm guessing that you don't actually want to print the directories, but rather process all of the regular files in a directory tree (including all of the subdirectories). If that's the case, you may want to take a look at the From memory, you probably want something like this (using the
In this example, all of the non-directory files in the entire tree (recursively) will be processed by |
|||
|
|