免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2815 | 回复: 0
打印 上一主题 下一主题

请教一个BAT 问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-15 11:02 |只看该作者 |倒序浏览
现在有一个FTP 自动上传的BAT脚本,每天早晚分别上传不同的两个文件。现在想通过下午上传文件后自动把删除掉FTP上一周前的文件给删掉,只保留最近一周的,能不能实现。
文件格式如下。

  1. 008-11-25  11:32         1,131,266 posSeller_2008-12-12早.BAK
  2. 008-11-25  11:32         1,131,266 posSeller_2008-12-12晚.BAK
  3. 008-11-25  11:32         1,131,266 posSeller_2008-12-13早.BAK
  4. 008-11-25  11:32         1,131,266 posSeller_2008-12-13晚.BAK
  5. 008-11-25  11:32         1,131,266 posSeller_2008-12-14早.BAK
  6. 008-11-25  11:32         1,131,266 posSeller_2008-12-14晚.BAK
  7. 008-11-25  11:32         1,131,266 posSeller_2008-12-15早.BAK
  8. 008-11-25  11:32         1,131,266 posSeller_2008-12-15晚.BAK
复制代码

每天都会有一个类似这样格式的两个文件
BAT 的脚本如下

  1. @echo off
  2. set dt=%date:~0,10%

  3. if "%time:~0,5%" geq " 7:00" (
  4.   if "%time:~0,5%" lss "12:00" (
  5.     goto _amftp
  6.   ) else if "%time:~0,5%" geq "12:00" (
  7.     if "%time:~0,5%" lss "24:00" (
  8.     goto _pmftp
  9.     )
  10.   )
  11. )

  12. :_amftp
  13. echo nfspos> up.txt
  14. echo nfspos>> up.txt
  15. echo binary>> up.txt
  16. echo hash>> up.txt
  17. echo cd /nfspos/foodcard>> up.txt
  18. echo put posSeller_%dt%早.BAK>> up.txt
  19. echo bye>> up.txt
  20. ftp -i  -s:up.txt  192.10.1.249
  21. del up.txt
  22. goto _end

  23. :_pmftp
  24. echo nfspos> up.txt
  25. echo nfspos>> up.txt
  26. echo binary>> up.txt
  27. echo hash>> up.txt
  28. echo cd /nfspos/foodcard>> up.txt
  29. echo put posSeller_%dt%晚.BAK>> up.txt
  30. echo bye>> up.txt
  31. ftp -i  -s:up.txt  192.10.1.249
  32. del up.txt
  33. goto _end

  34. :_end
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP