批处理实现FTP自动下载

Copy latest files

@echo off
for /f "tokens=*" %%f in ('dir /b /od /a-d F:\DB_BackUp\GAIA') do (
set GAIA=%%f)

echo 最新的文件是 %GAIA% 
for /f "tokens=*" %%f in ('dir /b /od /a-d F:\DB_BackUp\GAIA_NTLJ') do (
set GAIA_NTLJ=%%f)

echo 最新的文件是 %GAIA_NTLJ%

copy "F:\DB_BackUp\GAIA\%GAIA%" "F:\FTP\%GAIA%"
copy "F:\DB_BackUp\GAIA_NTLJ\%GAIA_NTLJ%" "F:\FTP\%GAIA_NTLJ%"

quit

FTP_DownLoad

echo off
set ftpIP=*****//ip
set ftpName=****//user
set ftpPwd=****//password
set dateTime=%date:~0,4%%date:~5,2%%date:~8,2%
set historyTime=%date:~0,4%%date:~5,2%%date:~8,2% 

set bakPath=H:\DB_Download\
set fileadd=%bakPath%ftp_tmp.txt
   
 ::自动生成脚本 
echo open %ftpIP%>%fileadd%
echo User %ftpName%>>%fileadd%
echo %ftpPwd%>>%fileadd%

echo prompt>>%fileadd%
echo mget *.bak>>%fileadd%
echo mdel *.bak>>%fileadd%

echo bye>>%fileadd% 
echo quit>>%fileadd% 
   
   
::执行ftp脚本 
ftp -ns:%fileadd% 
   
::删除自动生成的脚本 
del /f/q %fileadd% 

2013-03-24  11:25:10

posted @ 2013-03-24 11:25  AllanHao  阅读(480)  评论(0编辑  收藏  举报