Directory Inventory

S

Sash

I'm trying to find the names of every file in a directory within the
subdirectories. The directory "ALLImages" has many subdirectories and I'm
just trying to get a list of those file names. They don't have to be
separated or identified as being in a different directory -- just one big
list. I have the following code which I thought would loop through, but it
finds the first directory give me the list and stops. Any help would be
greatly appreciated

Dim MyPath, MyName, myFullPath, myFullName

Open "c:\Loaded_July2009.txt" For Output As #3
MyPath = "\\ImageServer\AllImages\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.

Do While MyName <> "" ' Start the directory loop.

If MyName <> "." And MyName <> ".." Then 'Don't sue . and ..
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
myFullPath = MyPath & MyName & "\*.tif" 'Get the images in
that directory
myFullName = Dir(myFullPath, vbDirectory)
Do While myFullName <> "" 'Start the file loop
myFullName = Dir
Debug.Print myFullName
Print #3, MyName
Loop
End If
End If

MyName = Dir ' Get next directory entry.
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top