jeremyforan
jeremyforan

Reputation: 1437

batch ftp script with DATE command not working

I am uploading a running a simple batch script which downloads a file from one server and uploads it to another. The file name is based on the previous day ie. 20111124.zip (YYYYMMDD). The script works fine on all the boxes I have tried it on, however when it is run on a colleagues windows 7 box it fails. The DATE command returns a zero. I have already tried setting the UAC to off but that did not resolve the issue. Any help would be greatly appreciated.

SETLOCAL
SET dwMONTH=%DATE:~4,2%
SET /A dwDAY=%DATE:~7,2%-1
IF %dwDAY% LSS 10 (SET dwDay=0%dwDay%)
SET dwYEAR=%DATE:~10,4%
SET dwDate=%dwYEAR%-%dwMONTH%-%dwDAY%
SET mydate=%dwYEAR%%dwMONTH%%dwDAY%
echo %mydate%

Upvotes: 0

Views: 958

Answers (1)

weberik
weberik

Reputation: 2706

Windows 7 doesnt include a day name, e.g. on windows XP %date% contains "Di 25.10.2011" (im on a german computer system) and Win7 only "25.10.2011", so your offset (7) is pointing to the wrong spot

Upvotes: 2

Related Questions