VBScript to detect today's modified files in a

2019-06-05 23:07发布

问题:

I need to get all the modified files inside a folder including the subfolders inside it, and copy them to another folder. How can it be done using VBScript or any other way to achieve this?

Thanks in advance,
Bibhu

回答1:

try this (copy files modified less than 24 hrs ago )

Set objFS = CreateObject("Scripting.FileSystemObject")
''# Directory to scan
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
Go( objFolder)

Sub Go(objDIR)
  If objDIR <> "\System Volume Information" Then
    For Each eFolder in objDIR.SubFolders
        Go eFolder
    Next
    For Each strFiles In objDIR.Files
        strFileName = strFiles.Name
        strFilePath = strFiles.Path         
            If DateDiff("h",strFile.DateLastModified,Now) < 24 Then
           objFS.CopyFile strFolder&"\"&strFileName,"c:\tmp"
        End If 

    Next    
  End If  
End Sub