Windows FTP via Batch Script
Normally when scripting using Windows FTP I use something like this:
Contents of ftp_backup.bat:
ftp -n -s:ftp.scr
Contents of ftp.scr:
open 123.456.789.101
user
username
password
cd BACKUPS
put C:\BACKUPS\mybackups.zip
quit
This automatically uploads mybackups.zip to my FTP everytime the batch script is secheduled to run. Normally this would be fine but it does have its limitations as you can't use varaibles like date in your script. So after playing around for a little while I worked out that I can do the above in a single batch file allowing me to use variables. Here's how:
Contents of ftp_backup_new.bat
@echo off
Set mm=%DATE:~4,2%
Set dd=%DATE:~7,2%
Set yyyy=%DATE:~10,4%
(echo open 123.456.789.101
echo user
echo username
echo password
echo cd BACKUPS
echo put C:\BACKUPS\mybackups__%yyyy%%mm%%dd%.zip
echo quit)>ftp.txt
ftp -n -s:ftp.txt
del ftp.txt