2017-02-15 82 views
1

我已经创建了一个批处理文件,以将文件从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

我改变了一些东西:我删除了回声。我在目标和文件列表声明中加入了引号。我也进入了文件列表文件,并将目录添加到fileList文件的文件名中。 – user2576682

+0

我得到的错误说文件名称,目录名称或卷标标签语法不正确。 – user2576682

回答

0

您的脚本有几个问题。当你正在调试它时,我会建议你暂时注释掉第一行@Echo off,这样你就可以看到发生了什么。

至于您的具体问题:if not exist不会为一个文件对象上的FTP位置的存在检查。它只适用于文件系统。

相关问题