tcbrogan
(tcbrogan)
1
I need to create a batch file to upload multiple files to a FTP server. Need to create a new directory each time with yesterday’s date being the directory name (YYYYMMDD). Any help would be greatly appreciated.
2 Spice ups
Once you are done creating your folder, call “ftp” from your batch file and pass it a text file with the ftp commands in it. Sorry I can’t be more specific right now
There are numerous ways you can accomplish this, from a batch file (example.bat) to a PowerShell Script. If both of these are new to you, I would recommend that you start with a batch file. PowerShell is (as the name implies) incredibly powerful, but it is not exactly new-user friendly.
If your FTP server requires a username and a password, I recommend that you use a third party application like WinSCP. Handling FTP credential negotiation in a batch script can be a real pain.
Password handling is not so much of a problem. I do it all the time. Just put the password in the ftp script. The problem is though, it’s difficult to modify that script, so you would have a hard time changing directory names and such. As Lumberjacked suggests, script WinSCP . I believe this will solve your problem. They even have a .Net library if you’re into coding.
Obviously, scripting the connection (no matter which tool you use) is the easy part. Automatically creating a folder with yesterday’s date is a bit tougher. Two options: schedule a task to create the folder at 11:59pm the night before you need it, or use the rather complicated scripts found here to calculate the date for the previous day: http://stackoverflow.com/questions/11891335/how-to-get-yesterdays-date-in-dos