VBScript parsing subfolders

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

VBScript parsing subfolders

Post by BlackWisdom » Mon May 09, 2005 7:02 pm

:D

Hi guys I have been working with this script - it works well - it copies the files for a specific date and extentsion - but I just cant figure out how to get it to copy the files that are in the subfolders in addition to whats in the root, I tried a few variations with no success - here is the current script:

VBSTART
Dim BackupFilesSigDate, filesys, oFolder, srcfolder, tgtfolder, oFile
BackupFilesSigDate = Date -1
srcfolder = "C:\"
tgtfolder = "24HrBackUp\"
Set filesys = CreateObject("Scripting.FileSystemObject")
Set oFolder = filesys.GetFolder(srcfolder)
If Err.Number 0 Then
Wscript.echo "The Source Folder does not exists. Operation aborted."
Set oFolder = Nothing
Set filesys = Nothing
Else
For Each oFile In oFolder.Files
If DateDiff("d", BackupFilesSigDate, oFile.DateCreated) = 0 Then
filesys.copyfile oFile.Path, tgtfolder & "\" & oFile.Name, True
End If
Next
End If
Set oFile = Nothing
Set oFolder = Nothing
Set filesys = Nothing
VBEND
VBRun>

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Mon May 09, 2005 8:21 pm

I guess you need to make it iterative so that it looks in each subfolder found on each parse.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts