mr_e_landis
Registered User.
- Local time
- Today, 02:39
- Joined
- Feb 16, 2005
- Messages
- 28
I'm working on a "Simple" project but it got a little complicated... As usual 
Its easy in DOS... You just run a Dir /S and viola... All your files including files in sub directories...
So far I've used the MS example code below and it works great!!!
In a nut shell this is what I'm doing... There is a root directory. Every folder in that root directory represents a catalog. Thats what the code above does such a fantastic job of. It returns a wonderful list of all the catalogs in the root directory. Now... I need to collect some information from every file in the catalog directory including any sub directories...
I'd like to do that by using the usual code below in a loop. Thats easy
The underlying issue is getting all the files... There may be 20 files just hang'in out in the Catalog directory or there may be 20 files total, 2 being in the Catalog directory and the rest scattered throughout various sub directories in the Catalog...
HOW CAN I GET A LIST OF ALL FILES INCLUDING FILES IN ALL SUBDIRECTORIES?

I've tried the following but agian. No files from subdirectories included in this...

Its easy in DOS... You just run a Dir /S and viola... All your files including files in sub directories...
So far I've used the MS example code below and it works great!!!
Code:
'''' Display the names in C:\ that represent directories.
'''MyPath = "c:\" ' Set the path.
'''MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
'''Do While MyName <> "" ' Start the loop.
''' ' Ignore the current directory and the encompassing directory.
''' If MyName <> "." And MyName <> ".." Then
''' ' Use bitwise comparison to make sure MyName is a directory.
''' If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
''' Debug.Print MyName ' Display entry only if it
''' End If ' it represents a directory.
''' End If
''' MyName = Dir ' Get next entry.
'''Loop
In a nut shell this is what I'm doing... There is a root directory. Every folder in that root directory represents a catalog. Thats what the code above does such a fantastic job of. It returns a wonderful list of all the catalogs in the root directory. Now... I need to collect some information from every file in the catalog directory including any sub directories...
I'd like to do that by using the usual code below in a loop. Thats easy

Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(<location here>)
f.size
f.name
Etc...
The underlying issue is getting all the files... There may be 20 files just hang'in out in the Catalog directory or there may be 20 files total, 2 being in the Catalog directory and the rest scattered throughout various sub directories in the Catalog...
HOW CAN I GET A LIST OF ALL FILES INCLUDING FILES IN ALL SUBDIRECTORIES?

I've tried the following but agian. No files from subdirectories included in this...
Code:
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
Last edited: