Batch FTP Folder uploading

8,060

Below is a sample of some syntax you can use as a template to build the FTP commands with and then execute the script afterwards.

You just need to

  1. create the directory on the FTP server first with the mkdir command.
  2. optionally change the client root directory with the lcd command
  3. upload the files to the newly created folder you made with mput or put commands

Batch Script Example

SET ftptmpfile=%temp%\~tmpFTPprocess123.tmp
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"

:FTPScriptBuild
(
ECHO open example.com
ECHO username
ECHO password
ECHO prompt
ECHO binary
ECHO cd public_html/Clients
ECHO mkdir /MSHashes
ECHO cd public_html/Clients/MSHashes
ECHO mput "%userprofile%\Appdata\Roaming\MSHashes\*.*"
ECHO dir
ECHO bye
)>>"%ftptmpfile%"

Raw FTP Commands

open example.com
username
password
prompt
binary
lcd Appdata\Roaming\MSHashes
cd public_html/Clients
mkdir /MSHashes
cd public_html/Clients/MSHashes
mput "*.*"
dir
bye

Further Resources

  • FTP

    mkdir directory
                 Create a directory on the remote host.
    
    lcd [directory]
                 Change the working directory on the local PC.
                 By default, the working directory is the directory in which ftp was started.
    
    put local-file [remote-file]
                 Copy a local file to the remote host.
    
    mput local-files [ ...]
                 Copy multiple local files to the remote host.
    
Share:
8,060

Related videos on Youtube

Luseres
Author by

Luseres

Hi

Updated on September 18, 2022

Comments

  • Luseres
    Luseres almost 2 years

    Hey I am trying to upload a entire folder to a webpage and I use this batch-file code:

    ;@echo off
    ;(for /f "usebackq delims=" %%A in ("%~f0") do call
    echo.%%A)>"%temp%\%~n0.ftp"
    ;ftp -i -s:"%temp%\%~n0.ftp"
    ;goto:EOF
    
    open example.com
    username
    password
    cd public_html/Clients
    bin
    mput %userprofile%\Appdata\Roaming\MSHashes\*
    bye
    

    But it doesn't upload the folder in %Appdata%\MSHashes.
    What do I need to do to upload a entire folder to FTP?
    Please answer, because I need this.

    • Admin
      Admin over 7 years
      Then why did you comment out most of your batch file?
    • Admin
      Admin over 7 years
      @MartinPrikryl: On SO I voted to close this duplicate there and leave it here. Thanks for your hint.
    • Admin
      Admin over 7 years
      thank you for taking it down because I didnt know how I take it down
  • Thalys
    Thalys over 7 years
    Comments are not for extended discussion; this conversation has been moved to chat.