Append date to log file names

Here's a simple script for a batch file to append the current date to log files.

As an administrator for a Windows network, scripting to automate tasks becomes more of a necessity. Here is a simple

script for a batch file to append the current date to log files:

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)
REM This sets a variable %date% to the current date.
REM Just append %date% to the log (output) file name.
REM Use >logfile%date%.log to create a new log file or >>logfile%date%.log to append to the log file.


This was first published in November 2001

Dig deeper on Microsoft Windows Systems and Network Management

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close