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

Define filetype/file extension in tree search 1

Status
Not open for further replies.

LinguaFranca

Technical User
Jan 4, 2005
18
NL
I need to tweak the code of the following piece of code so that not all files of all subfolders are picked up but only files of a specific file type I previously define. In my case I would like to search for *.frm, *.res and *.properties files. I tried several routes but wasn't successful in how to tell the script to look for files ending in *.frm. Found this code ín this forum and it works fine so far so I would like to take this as a basis for fine-tuning it.


Code:
Sub Main

	Call LoopFoldersListFiles("C:\CVS\en\ESI\11.1\UI\assets")

End Sub


Sub LoopFoldersListFiles(path As String)
' Need references to Microsoft Scripting Runtime
Dim fso As New FileSystemObject
Dim f As Folder, sf As Folder, fi As File

    Set f = fso.GetFolder(path)
    For Each sf In f.SubFolders
         LoopFoldersListFiles (sf.Path)
    Next
    For Each fi In f.Files
	PSL.Output fi.Path
    Next
End Sub
 
Something like this ?
Code:
...
For Each fi In f.Files
  strExt = LCase(Mid(fi.Path, 1+InStrRev(fi.Path,".")))
  If strExt = "frm" Or strExt = "res" Or strExt = "properties" Then
    PSL.Output fi.Path
  End If
Next
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks very much for this quick reply! It worked perfectly well and solved my problem.
Many thanks, Carmen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top