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 _
sDBFileExt = "pdf"
'If the backup folder doesn't exist, create it.
If Not objFSO.FolderExists(sBackupFolder) Then
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
Set objFSO = Nothing

Open in new window

Thanks in advance!
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
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