BAT 调用 VBS 通过curl 检查FTP中的文件日期

VBS调用curl 检查FTP中的文件日期,传入一个日期参数,然后ftp某个目录中的所有文件和这个日期进行比较.返回大于传入日期参数的个数.

 

Set objArgs = WScript.Arguments 

strTmp=now
If objArgs.Count>0  Then
 strTmp= objArgs(0)
End If

If Len(strTmp)=0 or objArgs.Count=0 Then
 strTmp=trim(inputbox("Entry Date","Date",strTmp ))
End If

If Len(strTmp)>0 Then
 strTmp=CDate(left(CDate(strTmp),11))
 
 'msgbox strTmp
 Set objShell = CreateObject("Wscript.Shell")

 SET A = objShell.exec("curl.exe ""ftp://xxxxxxx/"" -X  ""list -al"" -u username:password").stdout
 b = A.readall
 

 tmpLine= split(b,vbcrlf)
 

 iFileCount=0
 for i=0 to UBound(tmpLine)

    '读取文件列表中的每一行
    if Len(tmpLine(i))>0 And instr(tmpLine(i)," <DIR>")<=0 then
         tmpstr=CDate(Trim(left(tmpLine(i),25)))

         '日期比较
         If tmpstr>strTmp Then

          '计数
          iFileCount=iFileCount+1
         End If
         'msgbox tmpstr
    End if
 Next 
 

 '返回计数值
 'MsgBox iFileCount
 WScript.Quit(iFileCount)
 
end if

 

 

下面的bat 调用

 

echo off
ChkFTPFile.vbs %date%

'如果ftp上的文件日期大于当天的文件总数为11
if  ERRORLEVEL 11  run some commad

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值