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

Finding a folder in a directory tree

Status
Not open for further replies.

SUnderwood

Programmer
Nov 21, 2002
107
GB
Dear All,

I hope you can help with my simple problem.

I am trying to find a directory - say Foo:="S1234" - in a tree - say Bar:="w:\files\".

Whats the best method of finding that folder Foo in tree Far?


(Has anyone opened a pub called "The FooBar"?)

 
'use wmi to get all files with the uls* name
strDir = "f:\"
Set objDir = FSO.GetFolder(strDir)
getInfo(objDir)

'write results to a logfile
Set tsResults = FSO.CreateTextFile("c:\ULSTime.log", True)

For Each aKey In dicResults
tsResults.WriteLine aKey & "=" & dicResults.Item(aKey)
Next

tsResults.Close
Set tsResults = Nothing

'end of script part

'####################################################
Function getInfo(pCurrentDir)

For Each aItem In pCurrentDir.Files
'wscript.Echo aItem.Name
If LCase(Left(Cstr(aItem.Name), 3)) = "uls" Then
If LCase(Right(Cstr(aItem.Name), 3)) = "txt" Then
checkFile(aItem)
End If
End If
Next

For Each aItem In pCurrentDir.SubFolders
If LCase(aItem.Name) = "foobar" Then
msgbox "found foobar"
End If
'wscript.Echo aItem.Name & " passing recursively"
getInfo(aItem)
Next

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top