先运行download.bat- @echo off
- rem 指定FTP用户名
- set ftpUser=USERNAME
- rem 指定FTP密码
- set ftpPass=PASSWORD
- rem 指定FTP服务器地址
- set ftpIP=192.168.0.2
- rem 指定待下载的文件位于FTP服务器的哪个目录
- set ftpFolder=/SharedFile/Log\
- rem 指定从FTP下载下来的文件存放到本机哪个目录
- set LocalFolder=C:\temp\
-
- set ftpFile=%temp%\TempFTP.txt
- >"%ftpFile%" echo,%ftpUser%
- >>"%ftpFile%" echo,%ftpPass%
- >>"%ftpFile%" echo cd "%ftpFolder%"
- >>"%ftpFile%" echo lcd "%LocalFolder%"
- >>"%ftpFile%" echo bin
- >>"%ftpFile%" echo mget *.*
- >>"%ftpFile%" echo bye
- start ftp -v -i -s:"%ftpFile%" %ftpIP%
复制代码 ftp下载完成以后,再运行compare.bat- @echo off
- ::演示:用FTP下载的文件去更新本机的文件。
- ::如果演示结果无误,把copy前面的echo去掉,即可实现真正更新。
-
- rem 指定从FTP下载下来的文件存放到什么地方
- set LocalFolder=C:\test
- rem 指定待比较的本机文件存放到什么地方
- set CompareFolder=C:\dat
-
- for /f "skip=4 delims= " %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sTimeFormat') do (
- set "RegTimeOld=%%a"
- )
- set RegTimeOld=%RegTimeOld:~-8%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sTimeFormat /t REG_SZ /d H:mm:ss /f>nul
- >"%temp%\DownList.txt" type nul
- for /f "skip=5 delims=" %%a in ('dir "%LocalFolder%"^|findstr ":*[a-z]"') do (
- >>"%temp%\DownList.txt" echo %%a
- )
- >"%temp%\CompareList.txt" type nul
- for /f "skip=5 delims=" %%a in ('dir "%CompareFolder%"^|findstr ":*[a-z]"') do (
- >>"%temp%\CompareList.txt" echo %%a
- )
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sTimeFormat /t REG_SZ /d %RegTimeOld% /f>nul
- findstr /x /v /g:"%temp%\CompareList.txt" "%temp%\DownList.txt">"%temp%\CopyList.txt"
- for /f "usebackq tokens=4 delims= " %%a in ("%temp%\CopyList.txt") do (
- echo copy /y "%LocalFolder%\%%a" "%CompareFolder%"
- )
- pause
复制代码 首发:http://blog.csdn.net/ljc007/archive/2010/04/17/5497129.aspx |