Auto download - filename UCC-YYYYMMDD.zip format.

Hi,

On a daily basis I have download .zip file from FTP site. Naming convention of .zip is UCC-20100816.zip

I want to create windows batch file which will automatically download latest .zip file based on system date.

.zip file is gets uploaded on a daily basis on FTP site in UCC-YYYYMMDD.zip format.

Plz suggest.

Thankx,
Rahul Bahulekar.

You're in luck, I've had to do something similar in the last week. I found the date code on the net a while ago, I forget where.

SET currdate=%date%
SET mm=%currdate:~4,2%
SET dd=%currdate:~7,2%
SET yyyy=%currdate:~10,4%
SET filename=UCC-%yyyy%%mm%%dd%.zip

wget ftp://sitename/path/to/%filename%

You can get wget for windows here.

Generating YYYYMMDD depends on the reply to the MSDOS "date" command.
Mine replies "DD/MM/YYYY" (10 characters).

Generating the date on a UK Windows PC or Server in a MSDOS batch file.

@echo off
REM Format of date is DD/MM/YYYY
SET currdate=%date%
SET dd=%currdate:~0,2%
SET mm=%currdate:~3,2%
SET yyyy=%currdate:~6,4%
SET yyyymmdd=%yyyy%%mm%%dd%
echo %yyyymmdd%

20100817

You can also drive Microsoft FTP in a Windows Batch File. Whatever you type for your daily download session (including username and password) can be done from a Windows Batch File.

Thank you for pointing out that its output differs by region! Actually though, it depends on the %date% builtin, which is not a command. </nitpick>

Thank you for help!!!