开发者

VBScript to detect today's modified files in a folder (including subfolders inside it)

开发者 https://www.devze.com 2022-12-18 09:57 出处:网络
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?

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消