- 论坛徽章:
- 0
|
现在有一个FTP 自动上传的BAT脚本,每天早晚分别上传不同的两个文件。现在想通过下午上传文件后自动把删除掉FTP上一周前的文件给删掉,只保留最近一周的,能不能实现。
文件格式如下。
- 008-11-25 11:32 1,131,266 posSeller_2008-12-12早.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-12晚.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-13早.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-13晚.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-14早.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-14晚.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-15早.BAK
- 008-11-25 11:32 1,131,266 posSeller_2008-12-15晚.BAK
复制代码
每天都会有一个类似这样格式的两个文件
BAT 的脚本如下
- @echo off
- set dt=%date:~0,10%
- if "%time:~0,5%" geq " 7:00" (
- if "%time:~0,5%" lss "12:00" (
- goto _amftp
- ) else if "%time:~0,5%" geq "12:00" (
- if "%time:~0,5%" lss "24:00" (
- goto _pmftp
- )
- )
- )
- :_amftp
- echo nfspos> up.txt
- echo nfspos>> up.txt
- echo binary>> up.txt
- echo hash>> up.txt
- echo cd /nfspos/foodcard>> up.txt
- echo put posSeller_%dt%早.BAK>> up.txt
- echo bye>> up.txt
- ftp -i -s:up.txt 192.10.1.249
- del up.txt
- goto _end
- :_pmftp
- echo nfspos> up.txt
- echo nfspos>> up.txt
- echo binary>> up.txt
- echo hash>> up.txt
- echo cd /nfspos/foodcard>> up.txt
- echo put posSeller_%dt%晚.BAK>> up.txt
- echo bye>> up.txt
- ftp -i -s:up.txt 192.10.1.249
- del up.txt
- goto _end
- :_end
复制代码 |
|