Uploading a directory using Windows Command line FTP

155 pts.
Tags:
directory ftp upload
FTP
ftp upload
Windows Commands
windows ftp
I am having a problem wrapping my head around creating a very basic script to upload a directory to an FTP site. I am able to create a directory on the local machine to include the day and date in the directory name using the variables %day% and %date%. Using today's date, the result is a directory name being created as "1206_Files".

I now need to upload this directory to an FTP server with any files or subfolders included. I cannot find a way to upload a directory using the Windows Command line FTP. I tried instead to create a directory on the FTP server using the date and day variables that worked on the local machine. These do not work using the mkdir FTP command.

The variables come through as literal character resulting in a directory named "%day%%date%_files". So my questions are: - is there a way to upload a directory using the Windows command line FTP? (zipping the directory is not an option) - is there a way to create a directory on the FTP server using the date and day variables for the name? - is there a way to perhaps mirror a directory structure from a local machine to an FTP site?

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can use the MPUT statement to upload the entire folder. You’ll need to use the PROM statement so that it doesn’t prompt you to upload each file. Something like this.

BIN
PROM
MPUT *.*

You’ll still need to create the folder first as there isn’t a command to upload recursive folders over FTP.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • MicJ
    Thanks. I am comforatable with using MPUT for multiple files. My issue is either uploading a folder (which looks to be impossible) or creating a folder name using mkdir based on date variables from the uploading workstation and not the local time.
    155 pointsBadges:
    report
  • MicJ
    Found the wput command line tool. Am testing this out to see if it will meet my needs.
    155 pointsBadges:
    report
  • petkoa
    Hi, for the sake of mirroring you can try also rsync, specifically cwrsync for windows. However, you'll need to instal this on the server side also (if case of windows server) if you have admin rights there. BR, Petko
    3,120 pointsBadges:
    report
  • MicJ
    WPUT will not upload a directory but will do the entire contents of a directory. I am at the point where I need to issue an FTP command to create the directory on the remote FTP server but the name will change each day as the directory name is based on the date. I am thinking to rename the local directory under Windows on the local machine then gather this name into a file or variable in memory. How can I then issue a command like mkdir and reference either the variable in memory or the file containing the current name of the local directory?? Thanks
    155 pointsBadges:
    report
  • Asifshakeelmirza
    Thanks it is working...Thank you so much... But i want to upload files from sub-directories with cmd...Please help me in this as soon as you can. Thanks Again Asif Shakeel Mirza
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following