Logs Named By Current DateTime
I have a scheduled task and I’d like to save logs from the output. After some quick batch file work, I came up with this.
@echo off
setlocalfor /f "tokens=2" %%A in ('date /t') DO @(set MyDate=%%A)
set MyDate=%MyDate:/=-%set MyTime=%TIME::=-%
set MyTime=%MyTime:.=-%
set MyFilename=%MyDate%_%MyTime%.logecho Writing output to %MyFilename%
mytask.exe > %MyFilename%endlocal
I end up with filenames like 10-02-2009_14-34-56-00.log which gets the point across. Do you have a better way to accomplish this?
Comments
- Anonymous
October 13, 2010
The comment has been removed