VBScript - 复制过去 24 小时内修改过的文件 [英] VBScript - copy files modified in last 24 hours

查看:28
本文介绍了VBScript - 复制过去 24 小时内修改过的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从上次修改日期在当前日期的 24 小时内的目录中复制文件.我在文件路径中使用通配符,因为它每天都在变化;

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?

非常感谢

马丁.

推荐答案

怎么样:

filesystem.CopyFile "d:\x\logs\" & file.name, "d:\completed logs\"

这篇关于VBScript - 复制过去 24 小时内修改过的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆