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

会有一股神秘感。 提交于 2020-02-02 15:30:09

问题


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


来源:https://stackoverflow.com/questions/2146601/vbscript-to-detect-todays-modified-files-in-a-folder-including-subfolders-insi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!