[英]Batch file wont copy files
我创建了一个批处理文件,用于将文件从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
您的脚本存在一些问题。 当你正在调试它时,我会建议你暂时注释掉@Echo off
第一行@Echo off
这样你就可以看到发生了什么。
至于您的具体问题: if not exist
则不会检查 FTP位置上是否存在文件对象。 它只适用于文件系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.