3

I've got this .bat file:

ftp -s:commands.txt

File commands.txt:

open www.domain.nl
username
password
cd path/to/upload/to/
prompt

How can I now upload the folder where I ran the .bat to the server? It doesn't really matter if upload.bat and commands.txt get uploaded too.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Jonan
  • 143
  • 1
  • 2
  • 7
  • Note: Depending on how you are using FTP, it might be a good idea to _[find alternatives to FTP](http://blog.jdpfu.com/2011/07/10/why-you-need-to-stop-using-ftp)_ at some point... – summea Apr 22 '14 at 18:32
  • Also see: [How do I FTP multiple files from the command line?](http://superuser.com/questions/358099/how-do-i-ftp-multiple-files-from-the-command-line) – Ƭᴇcʜιᴇ007 Apr 22 '14 at 19:19

2 Answers2

8

You would use mput *.* (multiple put).

You may need to use lcd (local change directory), but not likely. I believe it defaults to the folder the command is run from.

Here is a list of commands you can use.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
Keltari
  • 71,875
  • 26
  • 179
  • 229
  • I just tested this, and it works fine for all the files directly in the current directory. However, it gives an error for subdirectories. How can I get this to work? – Jonan Apr 22 '14 at 20:01
  • unfortunately, with the Windows FTP client, you cant. You would have to use a 3rd party FTP program such as NcFTP - http://www.ncftp.com/ – Keltari Apr 22 '14 at 20:06
2

I'm not sure that the underlying FTP protocol provides for a recursive transfer of a directory. Your best bet is to zip it, send it, and then unzip the directory at the remote location.

Peter Mortensen
  • 12,090
  • 23
  • 70
  • 90
mdpc
  • 4,429
  • 9
  • 28
  • 36