Problem with Bat file

April 17, 2009 at 10:35:51
Specs: Windows XP
The Following bat file runs great except for on the 8th and 9th of the month. Can someone help me figure out why?

net use g: \\%2\rmdata
net use x: \\%1\programs

cd \AMSystems

for /f "tokens=2,3,4 delims=/ " %%i in ('date /t') do (
set /A my_day=%%j
set my_month=%%i
set my_year=%%k)

set my_year=%my_year:~2,2%

if %my_day%==0 set /A my_month-=1
if %my_month%==0 (
set my_month=12
set /A my_year-=1

set sysdate=%my_month%/%my_day%/%my_year%
set filedate=ME%my_month%%my_day%%my_year%
set my_file = info_%filedate%

set site=***

set rtekbatch=g:\MEcurrdate.opt


set rtspoolname=%filedate%.lst

set cobdir=x:

set path=x:


copy g:\%filedate%.lst \\fwstore1\rmdata\archive\ME

See More: Problem with Bat file

Report •

April 17, 2009 at 13:35:36
Your code is not fully clear to me, anyway pay attention to the pittfall of batch arithmetics as numbers starting with 0 are interpreted as octal so 08 and 09 can't exist.

Never operate with the /A switch on (decimal) numbers prefixed by 0. This leads to cumbersome coding, but there is no workaround than to strip out the leading zero and re-insert it after the operation.

Report •

April 17, 2009 at 16:16:12
set /A my_day = 1%%j - 100

Report •

Related Solutions

Ask Question