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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I search folders for a specific file?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Will someone provide sample code that will create a list of all folders on a drive. Then search each folder in that list for a specific filename.
 
Don't know if this will help you, but I pieced together pieces of code from this site to allow me to select a directory, look for all .bmp files in the selected folder and rename them a certain way if a condition was met.


I don't know exactly how to provide you your specific code, but this site has a lot of good stuff you can piece together and possibly solve your problem.
 
I took a few minutes out and put this togeather for you. Hope this is what you want

Dim fs

Dim ss
Dim sc
Dim s1
Dim s

Dim Fc
Dim F1
Dim F

Set fs = CreateObject("Scripting.FileSystemObject")

Set F = fs.GetDrive("c")
Set F = fs.GetFolder("c:\")
Set Fc = F.SubFolders

For Each F1 In Fc
Set s = fs.GetFolder(F1)
Set sc = s.Files
For Each s1 In sc

sname = LCase(s1)

If sname = lcase(s) & "\" & "name.xxx" Then
...
End If
Next


Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top