1

I am trying to transfer multiple files through FTP from a local directory - C:\Users\Documents\FTP\*.* to the Domain.

I've approached like the below.

First I've created a batch script DISCH.BAT as below ::

open ftp://UID@XXX.XXXXXX.net/outbound/Pre/Release/ 
USERNAME 
PASSWORD 
binary
mput C:\Users\Documents\FTP\*.*
quit

I've created another batch file RUN.BAT as below :

ftp -i -s:C:\Users\Desktop\DISCH.bat

When I am running the RUN.BAT ie., the second one, nothing is happening. Can you please advice where I am going wrong.

Thanks in advance.

METALHEAD
  • 2,734
  • 3
  • 22
  • 37
  • How do you run it? Did you run it from console window (`cmd.exe`) so that you can spot any errors? – Martin Prikryl Jun 21 '17 at 09:04
  • Though if you are trying to run a command-line ftp client from your C# application, instead of native C# code, it's a really bad solution: https://stackoverflow.com/q/44669001/850848 - And you did respond neither to my comment nor the answer yet! – Martin Prikryl Jun 21 '17 at 09:07
  • I am running it directly... Double clicking `RUN.BAT` – METALHEAD Jun 21 '17 at 09:13
  • So no wonder you cannot see what went wrong. Test it in the console. Or add `pause` at the end of the batch file. But anyway, you first have to fix the problem I have shown in my answer. – Martin Prikryl Jun 21 '17 at 09:19

1 Answers1

1

The argument to open is not URL, but only a hostname:

open XXX.XXXXXX.net

To enter the desired folder, use cd command after the credentials:

cd /outbound/Pre/Release/ 
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Hi Martin. Thank you for your answer. The FTP Path can be accessed with UID@Domain.NET but not with simple XXXX.net. Can there be a way I can use in this format..?? – METALHEAD Jun 21 '17 at 10:03
  • You specify the username in the `USERNAME` line in the script. Again, the `open` command takes only hostname, nothing else. All the other information has to be provided using other means. Command-line `ftp.exe` **does not use the concept URL**, which you may know from Windows explorer or other FTP clients. – Martin Prikryl Jun 21 '17 at 10:05