我创建了一个批处理文件,用于将文件从ftp服务器复制到共享驱动器。我是编写脚本的新手。当我运行.bat文件时,我收到错误"找不到源文件夹"。如果我使用WINSCP,我可以进入目录并查看没有问题的文件。
@Echo Off
ftp xxxxxx.org xxx
Set _UserName=xxxxxxxx
Set _Password=xxxxxxxx
set Source=ftp://ftp.xxxxxx.org/LOPE/mobiledoc
set Target=Z:\Scanned_Documents\LOPE
set FileList=Z:\Scanned_Documents\LOPE\FileList_LOPE.idx
if exist Z:\Scanned_Documents\LOPE\NUL echo "Folder already exists"
if not exist Z:\Scanned_Documents\LOPE\NUL echo "Folder does not exist"
if not exist "%Source%" echo Source folder "%Source%" not found & goto Exit
if not exist "%FileList%" echo File list "%FileList%" not found & goto Exit
if not exist "%Target%" md "%Target%"
for /F "delims=" %%a in ('type "%FileList%"') do copy "%Source%\%%a" "%Target%"
:Exit
echo.
echo press the Space Bar to close this window.
pause > nul
答案 0 :(得分:0)
您的脚本存在一些问题。在您进行调试时,我建议您暂时注释掉第一行@Echo off
,以便了解正在发生的事情。
至于您的具体问题:if not exist
不会检查是否存在FTP位置上的文件对象。它只适用于文件系统。