Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file logging question  (Read 2147 times)

0 Members and 1 Guest are viewing this topic.

dpisarek

  • Guest
Batch file logging question
« on: April 04, 2006, 09:07:42 AM »
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.

dpisarek

  • Guest
Re: Batch file logging question
« Reply #1 on: April 04, 2006, 02:28:15 PM »
This was answered:

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

Thanks all.

DosItHelp



    Intermediate
    Re: Batch file logging question
    « Reply #2 on: April 04, 2006, 06:54:25 PM »
    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%

    « Last Edit: April 04, 2006, 06:55:21 PM by DosItHelp »