3

I need to upload a set of .txt files to an FTP server using a .bat file. So far, I've managed to connect to the FTP server, including the correct directory that I need to put the file into and then disconnect. However, it isn't uploading the files.

In my .bat file, I've got this line to start the process

ftp -s:ftp.txt

Then, in ftp.txt, I've got

open my.ip.address
myUserName
myPassword
binary
cd myDir
cd myDir
put C:\MyFolder\*
quit

It goes to the correct directory when I run the batch file, the output being

OK. Current directory is /myDir/MyFolder

ftp> put C:\MyFolder*

Error opening local file C:\MyFolder..

ftp> quit

Goodbye. You uploaded and downloaded 0 kbytes.

Why is it erroring when trying to upload all files from C:\MyFolder\? Is there another way to upload all of the files from a folder?

Community
  • 1
  • 1
David
  • 2,298
  • 6
  • 22
  • 56

1 Answers1

1

put is used for a single file. To upload multiple files, use mput instead.

mput C:\MyFolder\*

You may also want to put a prompt on the line before the mput line so that you aren't prompted to press Y for each file in the folder.

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
  • Thanks! Currently when it's uploading the file it shows the command prompt window, which I don't want it to do. How do I hide this? – David Feb 16 '18 at 10:49
  • @David That's a completely separate question, so ask it separately. Plus you need to tell us, how do you run the `.bat` file. – Martin Prikryl Feb 16 '18 at 10:51