Rename log file

I needed to automate renaming log files because the size of the log file was slowing down the application. Here is the resulting batch file.

@echo off

set CURRDATE=%TEMP%\currdate.tmp

date /t > %CURRDATE%

set PARSEARG=”eol=; tokens=1,2,3,4* delims=/, ”
for /f %PARSEARG% %%i in (%CURRDATE%) do set YYYYMMDD=%%l%%k%%j

ren file.log file_%YYYYMMDD%.log

Leave a Reply