拷贝增量文件

Dim fso, CopyCount


Set fso = CreateObject("Scripting.FileSystemObject")


CopyCount = CopyCount + XCopy(fso, "D:\app\lieboscm\upload", "J:\upload", True)


MsgBox "拷贝了" & CopyCount & "个文件!"


'********************************************************************


'* Function :     XCopy


'*


'* Purpose:  复制文件和目录树。


'*


'* Input:    fso            FileSystemObject 对象实例


'*           source         指定要复制的文件。


'*           destination    指定新文件的位置和/或名称。


'*           overwrite      是否覆盖已存在文件。 Ture 覆盖, False 跳过


'*


'* Output:   返回复制的文件个数


'*


'********************************************************************


Function XCopy(fso, source, destination, overwrite)


    Dim s, d, f, l, CopyCount,timespec,time2


    timespec = 24*4
    time2= "2014-08-13 02:00:00"
    Set s = fso.GetFolder(source)


    If Not fso.FolderExists(destination) Then


        fso.CreateFolder destination


    End If


    Set d = fso.GetFolder(destination)


    CopyCount = 0


    For Each f In s.Files


        




        If DateDiff("h", f.DateCreated ,time2) < timespec then
         
        l = d.Path & "\" & f.Name  


        f.Copy l, True
        CopyCount = CopyCount + 1


        End If


        


        


       
    Next


    For Each f In s.SubFolders


        CopyCount = CopyCount + XCopy(fso, f.Path, d.Path & "\" & f.Name, overwrite)


    Next


    XCopy = CopyCount


End Function
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值