Computing Staff
  • 1

.Bat Upload To FTP Entire Folder – HELP!

  • 1

This is my code so far:

@Echo Off
Echo *NAME*> ftpcmd.txt
echo *PASSWORD*>> ftpcmd.txt
echo binary>> ftpcmd.txt
echo prompt n>>ftpcmd.txt
echo mget *.html>> ftpcmd.txt
echo bye >> ftpcmd.txt
ftp -s:ftpcmd.txt ftp.drivehq.com
del ftpcmd.txt

I’m trying to get *\My Documents\My Chatlogs\ sent to the FTP, the entire folder with subfolders.

If I use:
echo cd My Documents\My Chatlogs
with
echo mpget *.*
It still doesn’t work.

It either will say ‘Permission Denied’, or it just won’t transfer it.

So how can I get a .bat to upload an ENTIRE folder and subfolders to a remote FTP?

Thanks.

Share

2 Answers

  1. might try this modification ( [ ] are just for reference):
    [echo prompt n>>ftpcmd.txt]
    for /f “tokens=* delims=” %%a in (‘dir /b /s /ad’) do echo mput %%a\*.html>> ftpcmd.txt
    [echo bye >> ftpcmd.txt]
    alot depends on if you want local dir. structure mirrored on remote.

    • 0
  2. How can I get .bat to upload to FTP an ENTIRE folder and subfolders?

    Check out http://www.biterscripting.com/helpp… .

    That script mirrors an entire local folder from a
    local computer to a remote FTP server. Will
    create the subfolders as necessary.
    Call the script like this from biterscripting.

    script "C:/Scripts/SS_FTPUpload.txt" 
      localpath("/website") remotepath("/")
      ftpserver("ftp.server.com") ftplogin("login") ftppassword("pswd")
    

    (Enter the entire command on one line. I had to split it to make it visible.)

    “/website”
    path to local folder

    “/”
    path on the FTP server.

    “ftp.server.com”
    FTP Server

    “login”
    your login

    “pswd”
    your password

    So, for example, if the local computer has following files,

    /mywebsite/index.html
    /mywebsite/log.gif
    /mywebsite/fruits/apple.html
    /mywebsite/fruits/apple.gif
    /mywebsite/fruits/addfruit.pl

    the FTP server will have the following files.

    /index.html
    /log.gif
    /fruits/apple.html
    /fruits/apple.gif
    /fruits/addfruit.pl

    The folder ‘fruits’ will be created if it does not exist. Will upload .html and .gif files in correct (ascii, binary) mode.

    The script does somethings similar to why2u’s script – it creates a file containing commands around the local directory structure. The link has the code for the script, so you can modify.

    • 0