Uploading files to an FTP server via a batch file

12,759

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.

Share:
12,759
David
Author by

David

Yo

Updated on June 08, 2022

Comments

  • David
    David almost 2 years

    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?

  • David
    David about 6 years
    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?
  • Martin Prikryl
    Martin Prikryl about 6 years
    @David That's a completely separate question, so ask it separately. Plus you need to tell us, how do you run the .bat file.