VBScript subfolders RRS feed

  • Question

  • So I need help adding in to this Script so it will also search and copy files from the directories Subfolders also. I have been trying to do this but everything I try just lets me only copy the source folder.

    Dim SOURCE, TARGET, fso, SourceObj, TargetObj, FileObj
    SOURCE = "C:\Users\1385741622A\Desktop\Current 68's"
    TARGET = "C:\Users\1385741622A\Desktop\Due 68's\"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set SourceObj = fso.GetFolder(SOURCE)
    For Each fileObj in SourceObj.Files
        If (InStr(1, FileObj.Name,"AF68-",vbTextCompare) = 1) And _
                (DateDiff("d", fileObj.DateLastModified, Now) > 10) Then
            fileObj.Copy (TARGET)
        End If

    I have left out my attempt at including the subfolders Since it only gives me errors. This is a working Script.

    • Edited by LonePenguin Thursday, December 4, 2014 9:01 PM
    Thursday, December 4, 2014 8:55 PM


All replies