computing
  • 3

Copy Files Modified In Last Hour Batch

  • 3

I wish to create a batch file which will copy image files created in the last hour to another folder. Note I only want to copy files with a .jpg extension.

Can anyone help with this?

Share

1 Answer

  1. VBScript copies files modified up to an hour ago:

    Const srcDir = "c:\images"
    Const destDir = "c:\SomeWittyName"
    hourAgo = DateAdd("h", -1, Now)
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    For Each f In fso.GetFolder(srcDir).Files
      If  LCase(fso.GetExtensionName(f)) = "jpg" _
      And f.DateLastModified > hourAgo Then _
        f.Copy destDir & ""
    Next 'f

    • 0