2017-02-15 48 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位置的存在檢查。它只適用於文件系統。