Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Simple Batch script help

Jul 26, 2005 7:16AM PDT

Can someone please tell me why this will not work. I have tried so many different variations and syntax and cannot get it to cycle properly. Any help would be appreciated, thanks.

@ECHO on

FOR /F "usebackq tokens=1-3" %%i IN (`date /t`) DO set day = %%i
IF /i "%day%"==wed GOTO :backup ELSE GOTO :end

:backup
echo backing up

:end
echo ending

Discussion is locked

- Collapse -
What OS?
Jul 26, 2005 7:18AM PDT

That doesn't look like DOS to me.

Bob

- Collapse -
OS is Win2k & XP
Jul 26, 2005 7:32AM PDT

Sorry, this is a batch script for Windows XP and 2000 machines

- Collapse -
Not a NT CMD batch file person.
Jul 26, 2005 8:24AM PDT

However that one line...

IF /i "%day%"==wed GOTO :backup ELSE GOTO :end

Tells me you want this to run if it's wednesday. The old DOS trick to doing this was have two batch files. The first contained 2 lines.

DATE > next.bat < crfile.txt
NEXT

crfile.txt contained a few carriage returns. The next.bat will be created and will invoke THE.BAT and pass the date and time along in parameters.

THE.BAT could say...

if %5==Wed goto backup

You can mull over the old method.

Bob

- Collapse -
(NT) (NT) Thanks
Jul 26, 2005 9:10AM PDT