简体   繁体   中英

Batch file to copy local folder to FTP server fails with “cannot open file” on “put *”

I found some posts on similar issues but I did not make my problem to work. I want to use Windows Task on Windows Server 2012 to copy the content of some folders to back them up on a FTP server.

I created a filebakup.bat and entered these lines

@echo off
echo user myusername> ftpcmd.dat
echo mypassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo lcd /D "G:\Navi_Touren\Tour_2015\">> ftpcmd.dat   *the local dir with many files to transfer
echo cd /backups/Tour_2015>> ftpcmd.dat  *the Destination Folder on ftp  
echo put *>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat myFTPserver.com

It does not work, it says "cannot open file" or similar error message.

I can only make it with one file

echo put "G:\Navi_Touren\Tour_2015\myfile.txt"  "/backups/Navi Touren/myfile.txt">> ftpcmd.dat

But how to transfer all files in a certain directory?

Thanks Michael

You need to use the mput * , instead of the put . The put does not accept wildcards.

Plus you want to use the prompt to disable confirmation of every selected file.

prompt
mput *

See also Batch file to upload all files in directory to FTP .


Also there no /D switch in the lcd command. Remove that. And the trailing backslash does not seem to work either.

lcd "G:\Navi_Touren\Tour_2015"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM