troubleshooting Question

Code will not search subfolders.

Avatar of donnie91910
donnie91910 asked on
VB Script
7 Comments1 Solution45 ViewsLast Modified:
I have written search code to find files on my computer.  The problem that I am having is that the code will not search in subfolders.  Is there a way to make my code do that?  Here is the code:

Dim objFSO
Dim sSourceFolder
Dim sDestFolder
Dim sDBFile
Dim sDateTimeStamp
Set objFSO = CreateObject("Scripting.FileSystemObject")
sSourceFolder = "C:\Oceanside\"
sBackupFolder = "C:\Files_Found\"

sDBFile = array _
("ROWP19-0499","ROWP19-0543","ROWP19-0544","ROWP19-0545","ROWP19-0550","ROWP19-0559","ROWP19-0562","ROWP19-0567","ROWP19-0645")
sDBFileExt = "pdf"
 
'If the backup folder doesn't exist, create it.
If Not objFSO.FolderExists(sBackupFolder) Then
    objFSO.CreateFolder(sBackupFolder)
End If
 
'Copy the file as long as the file can be found
For i = 0 to Ubound(sDBFile)
If objFSO.FileExists(sSourceFolder & "\" & sDBFile(i) & "." & sDBFileExt) Then
		objFSO.CopyFile sSourceFolder & "\" & sDBFile(i) & "." & sDBFileExt,_
					  sBackupFolder & "\" & sDBFile(i) & "." & sDBFileExt
		MsgBox sSourceFolder & "\" & sDBFile(i) & "." & sDBFileExt & " was copied to " & sBackupFolder
	End if
Next 
Set objFSO = Nothing
Thanks in advance!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros