VBScript - copy files modified in last 24 hours
- by Martin North
Hi, I'm trying to copy files from a directory where the last modified date is within 24hours of the current date. I'm using a wildcard in the filepath as it changes every day I'm using;
option explicit
dim fileSystem, folder, file
dim path
path = "d:\x\logs"
Set fileSystem = CreateObject("Scripting.FileSystemObject")
Set folder = fileSystem.GetFolder(path)
for each file in folder.Files
If DateDiff("d", file.DateLastModified, Now) < 1 Then
filesystem.CopyFile "d:\x\logs\apache_access_log-*", "d:\completed logs\"
WScript.Echo file.Name & " last modified at " & file.DateLastModified
end if
next
Unfortunately this seems to be copying all files, and not just the recently modified ones. Can anyone point me in the right direction?
many thanks
Martin.