1.

Solve : Batch file logging question?

Answer»

I am using the following to del an old log file that a batch file creates:

if exist directory\log del directory\log

What I would like to know is how to create a new log each TIME the batch file is ran with the date and time included in the file name. So I have a RUNNING COUNT of each time the batch file was ran and when it was ran.

Any help would be appreciated.This was answered:

if exist stop.log ren stop.log stop_%%c%%a%%b%%t.log

Thanks all.How to make a unique string out if %date% and %time% is described here:

http://dostips.cmdtips.com/DtCodeSnippets.php#_Toc129970589

The created string can be USED as as target file name:


Code: [SELECT]for /f "tokens=2-8 delims=/:. " %%A in ("%date%:%time: =0%") do set UNIQUE=%%C%%A%%B%%D%%E%%F%%G
ren stop.log stop_%UNIQUE%



Discussion

No Comment Found