2015-10-30 105 views
2

無法通過文件將文件傳輸到ftp。敬請告知。感謝幫助通過Windows批處理腳本中的文件傳輸到FTP文件

test.ftp

open ftp2.xxx.com 
    xxx 
    xxxxx 
下面

是蝙蝠

set "ftptarget=ftp://ftp2.xxx.com/" 
ftp -i -s:test.ftp 

for /f "delims=" %%A in ('findstr /s /m /l /c:"100000" "%source%\*"') do (copy /y "%%A" "%ftptarget%") 
+0

有什麼不對?任何錯誤消息?向我們展示腳本輸出。 –

+0

其顯示ftp> cmd – william123456

+0

首先,建立完整的ftp腳本,然後運行'ftp',例如:[FTP目錄上傳](http://stackoverflow.com/a/28778802) – wOxxOm

回答

0

我張貼的文章很多很久以前這不(我覺得)你想要什麼: http://www.howtogeek.com/50359/upload-files-to-an-ftp-site-via-a-batch-script/

此腳本接受文件名作爲參數,或者您可以指定包含要上載的文件列表的文本文件。如果您需要上傳符合特定條件的文件(只需將DIR輸出寫入文本文件並提供文本文件作爲參數),則後一個選項非常有用。

如果沒有別的,它應該提供一個如何使用內置FTP命令的工作示例。

這裏是從上面的鏈接腳本:

@ECHO OFF 
REM Usage -- save this script as "UploadToFTP.bat": 
REM UploadToFTP [/L] FileToUpload 
REM 
REM Required Parameters: 
REM FileToUpload 
REM  The file or a text file containing the list of files to be uploaded. 
REM 
REM Optional Parameters: 
REM /L When supplied, the FileToUpload is read as a list of files to be uploaded. 
REM  A list of files should be a plain text file which has a single file on each line. 
REM  Files listed in this file must specify the full path. 

SETLOCAL EnableExtensions 

REM Connection information: 
SET Server= 
SET UserName= 
SET Password= 

REM ---- Do not modify anything below this line ---- 

SET Commands="%TEMP%SendToFTP_commands.txt" 

REM FTP user name and password. No spaces after either. 
ECHO %UserName%> %Commands% 
ECHO %Password%>> %Commands% 

REM FTP transfer settings. 
ECHO binary >> %Commands% 

IF /I "%~1"=="/L" (
    REM Add file(s) to the list to be FTP'ed. 
    FOR /F "usebackq tokens=*" %%I IN ("%~dpnx2") DO ECHO put "%%~I" >> %Commands% 
) ELSE (
    ECHO put "%~dpnx1" >> %Commands% 
) 

REM Close the FTP connection. 
ECHO close >> %Commands% 
ECHO bye >> %Commands% 

REM Perform the FTP. 
FTP -d -i -s:%Commands% %Server% 

ECHO. 
ECHO. 

REM Clean up. 
IF EXIST %Commands% DEL %Commands% 

ENDLOCAL 
相關問題