![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-11 23:52 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 请教如何判断FTP服务器中文件夹是否存在! |
| 可打印版本 1,323 / 2 |
| 第1楼 cguzh | 发表于 2010-07-12 11:36 |
| 新手上路 发帖 5 积分 12 | |
|
请教如何判断FTP服务器中文件夹是否存在! 我需要登录到一个FTP服务器上,上传文件。比如MPUT,BIN命令什么的都晓得。但有个问题是,我想FTP登录后先判断文件夹是否存在。我知道DOS中可以有命令直接判断本地的。比如 if not exist文件夹是否存在,但我登录到FTP 后这样写就不行了。
谢谢! |
|
| 第2楼 wwbh | 发表于 2010-09-04 21:02 |
| 新手上路 发帖 3 积分 4 | |
|
http://www.dostips.com/DtTipsFtpBatchScript.php#Batch.FtpBatchUploadOnlyNewFiles
http://hi.baidu .com/wangbaohua3/blog/item/d347e20a503146e937d1220c.html @Echo Off Setlocal Enabledelayedexpansion REM -- Define File Filter, i.e. files with extension .txt Set FindStrArgs=/E /C:".txt" REM -- Extract Ftp Script to create List of Files Set "FtpCommand=ls" Call:extractFileSection "" "-">"%temp%\%~n0.ftp" Rem Notepad "%temp%\%~n0.ftp" REM -- Execute Ftp Script, collect File Names Set "FileList=" For /F "Delims=" %%A In ('"Ftp -v -i -s:"%temp%\%~n0.ftp"|Findstr %FindStrArgs%"') Do ( Call Set "FileList=%%FileList%% "%%A"" ) REM -- Extract Ftp Script to upload files that don't exist in remote folder Set "FtpCommand=mput" For %%A In (%FileList%) Do set "Exist=Y" For /F "Delims=" %%A In ('"dir /b "%localdir%"|Findstr %FindStrArgs%"') Do ( If Not defined Exist Call Set "FtpCommand=%%FtpCommand%% "%%~A"" ) Call:extractFileSection "" "-">"%temp%\%~n0.ftp" rem Notepad "%temp%\%~n0.ftp" For %%A In (%FtpCommand%) Do Echo.%%A REM -- Execute Ftp Script, download files ftp -i -s:"%temp%\%~n0.ftp" Del "%temp%\%~n0.ftp" GOTO:EOF :extractFileSection StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark :: -- StartMark - start mark, use '...:S' mark to allow variable substitution :: -- EndMark - optional end mark, default is first empty line :: -- FileName - optional source file, default is THIS file :$created 20080219 :$changed 20100205 :$categories ReadFile :$source http://www.dostips.com SETLOCAL Disabledelayedexpansion set "bmk=%~1" set "emk=%~2" set "src=%~3" set "bExtr=" set "bSubs=" if "%src%"=="" set src=%~f0& rem if no source file then assume THIS file for /f "tokens=1,* delims=]" %%A in ('find /n /v "" "%src%"') do ( if /i "%%B"=="%emk%" set "bExtr="&set "bSubs=" if defined bExtr if defined bSubs (call echo.%%B) ELSE (echo.%%B) if /i "%%B"=="%bmk%" set "bExtr=Y" if /i "%%B"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y" ) EXIT /b |
|
| 第3楼 etmanc | 发表于 2010-09-04 23:47 |
| 新手上路 发帖 1 积分 1 | |
|
谢了,楼主
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |