摘自Batcher的代码
- @echo off
- rem 指定FTP用户名
- set ftpUser=asx
- rem 指定FTP密码
- set ftpPass=asx-asx
- rem 指定FTP服务器地址
- set ftpIP=172.19.103.7
- rem 指定待下载的文件位于FTP服务器的什么位置
- set ftpFolder=/export/home/PROD/ntcdata
- rem 指定从FTP下载下来的文件存放到什么地方
- set DownFolder=E:\Temp
- set DownFolder2=E:\Temp2
- rem 指定下载几天前的文件
- set DaysAgo=1
- set ftpDir=%temp%\TempDir.txt
- set ftpDown=%temp%\TempDown.txt
-
- rem 假设本机日期格式为yyyy-mm-dd
- set FileY=%date:~0,4%
- call :DateToDays %date:~0,4% %date:~5,2% %date:~8,2% PassDays
- set /a PassDays-=DaysAgo
- call :DaysToDate %PassDays% DstYear DstMonth DstDay
-
- >"%ftpDir%" echo.%ftpUser%
- >>"%ftpDir%" echo.%ftpPass%
- >>"%ftpDir%" echo bin
- >>"%ftpDir%" echo cd "%ftpFolder%"
- >>"%ftpDir%" echo dir * "%temp%\FileList.txt"
- >>"%ftpDir%" echo bye
- start ftp -v -i -s:"%ftpDir%" %ftpIP%
-
- rem 根据实际情况自行调节延迟时间
- ping -n 200 127.1 >nul
-
- findstr /i ":*\.SWM$" "%temp%\FileList.txt">"%temp%\FileDate.txt"
- findstr /i ":*\.TWM$" "%temp%\FileList.txt">>"%temp%\FileDate.txt"
- findstr /i ":*\.OWM$" "%temp%\FileList.txt">>"%temp%\FileDate.txt"
-
- >"%ftpDown%" echo.%ftpUser%
- >>"%ftpDown%" echo.%ftpPass%
- >>"%ftpDown%" echo bin
- >>"%ftpDown%" echo cd "%ftpFolder%"
- (for /f "usebackq tokens=1-9 delims= " %%a in ("%temp%\FileDate.txt") do (
- setlocal enabledelayedexpansion
- if "%%f" equ "Jan" (
- set FileM=01
- ) else if "%%f" equ "Feb" (
- set FileM=02
- ) else if "%%f" equ "Mar" (
- set FileM=03
- ) else if "%%f" equ "Apr" (
- set FileM=04
- ) else if "%%f" equ "May" (
- set FileM=05
- ) else if "%%f" equ "Jun" (
- set FileM=06
- ) else if "%%f" equ "Jul" (
- set FileM=07
- ) else if "%%f" equ "Aug" (
- set FileM=08
- ) else if "%%f" equ "Sep" (
- set FileM=09
- ) else if "%%f" equ "Oct" (
- set FileM=10
- ) else if "%%f" equ "Nov" (
- set FileM=11
- ) else if "%%f" equ "Dec" (
- set FileM=12
- )
- set FileD=10%%g
- set FileD=!FileD:~-2!
- if "!FileM!" equ "%DstMonth%" (
- if "!FileD!" equ "%DstDay%" (
- echo get "%%i" "%DownFolder%\%%i"
- )
- )
- endlocal
- ))>>"%ftpDown%"
复制代码
set FileD=10%%g
set FileD=!FileD:~-2!
if "!FileM!" equ "%DstMonth%" (
if "!FileD!" equ "%DstDay%" (
echo get "%%i" "%DownFolder%\%%i"
)
)
请教如上小部分代码中,要修改"!FileM!" "!FileD!"(连接一起组成的数字) 小于及等于 "%DstDay%"要怎样修改呢? |