简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

vbs实现只复制比目标文件更新的文件

来源:易贤网   阅读:1145 次  日期:2016-06-22 08:55:14

温馨提示:易贤网小编为您整理了“vbs实现只复制比目标文件更新的文件”,方便广大网友查阅!

代码如下:

@echo off

::每5分钟复制以下首页

for /f %%i in ('dir /b c:\index2.htm') do (

set indexdx=%%~zi

)

if %indexdx% gtr 5120 (

echo y | xcopy c:\index2.htm /d /r /k c:\index.htm

)

其中for /f %%i in ('dir /b c:\index2.htm') do (

set indexdx=%%~zi

)

是bat中获取index2.htm文件大小的。

然后通过if %indexdx% gtr 5120 (

实现判断是不是大于5120个字节

主要就是下面这个代码了功能更强,也比较简单

代码如下:

dim fso

set fso = createobject(scripting.filesystemobject)

set fn2=fso.getfile(c:\index2.htm)

flsize2=fn2.size

fldate2=fn2.datelastmodified

set fn=fso.getfile(c:\index.htm)

flsize1=fn.size

fldate1=fn.datelastmodified

if fso.fileexists(c:\index2.htm) and flsize2>50000 and fldate2>fldate1 then

fso.getfile(c:\index2.htm).copy(c:\index.htm)

if err.number=0 then writehistory 成功&now(),log.txt

end if

sub writehistory(hischars, path)

const forreading = 1, forappending = 8

dim fso, f

set fso = createobject(scripting.filesystemobject)

set f = fso.opentextfile(path, forappending, true)

f.writeline hischars

f.close

end sub

更多信息请查看脚本栏目
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:js判断钱格式
下一篇:jquery搜索框效果实现方法
易贤网手机网站地址:vbs实现只复制比目标文件更新的文件
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!