Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have been using a batch file with findstr to search various files for a specific string and print the file the string is found in.
I am interesed in upgrading this batch file to VB6, but can't find any commmands that will search multiple files and paths.
Can anyone offer assistance?

Here's a routine a wrote for someone that might help you accomplish your task (basically it find all files within a directory, and its subdirectories, using a recursive function):
http://www.experts-exchange.com/Q_21033463.html
-----
Dim AllFolders As New Collection
Private Sub GetSubFolders(ByVal Directory As String)
Dim FSO, tmpGet, tmpSub, tmpFolder
Dim CurrentFolders As New CollectionSet FSO = CreateObject("Scripting.FileSystemObject")
Set tmpGet = FSO.GetFolder(Directory)
Set tmpSub = tmpGet.SubFoldersFor Each tmpFolder In tmpSub
If Right$(Directory, 1) = "\" Then
AllFolders.Add Directory & tmpFolder.Name
CurrentFolders.Add Directory & tmpFolder.Name
Else
AllFolders.Add Directory & "\" & tmpFolder.Name
CurrentFolders.Add Directory & "\" & tmpFolder.Name
End If
NextFor Each tmpFolder In CurrentFolders
GetSubFolders (tmpFolder)
Next
End SubPrivate Sub GetFiles(ByVal Directory As String)
Dim FSO, tmpGet, tmpSub, tmpFile
Dim CurrentFiles As New CollectionSet FSO = CreateObject("Scripting.FileSystemObject")
Set tmpGet = FSO.GetFolder(Directory)
Set tmpSub = tmpGet.FilesFor Each tmpFile In tmpSub
processfile (tmpFile) 'Use your function here, this is the loop for each file
Next
End SubPrivate Sub Form_Load()
Dim tmpFolderGetSubFolders ("C:\My Music") 'Change this path to whatever you need
For Each tmpFolder In AllFolders
GetFiles tmpFolder
Next
End Sub-----
Good luck :-)
-Burbble

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |