VBScript - copy files modified in last 24 hours
Posted
by Martin North
on Stack Overflow
See other posts from Stack Overflow
or by Martin North
Published on 2010-06-09T10:04:43Z
Indexed on
2010/06/09
12:22 UTC
Read the original article
Hit count: 265
vbscript
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.
© Stack Overflow or respective owner