This shows you the differences between two versions of the page.

Link to this comparison view

batlogdate [2014/10/25 21:52]
batlogdate [2014/10/25 21:52] (current)
Line 1: Line 1:
 +== Generate log files from Bat files ==
 +Many times a batch file needs to redirect output to a time stamped log file. The following example generates such a logfilename.
 +<code bat>
 +@echo off
 +for /f "​tokens=1-4 delims=/ " %%a in ("​%date%"​) DO set WD=%%a ​
 +for /f "​tokens=1-4 delims=/ " %%a in ("​%date%"​) DO set MM=%%b
 +for /f "​tokens=1-4 delims=/ " %%a in ("​%date%"​) DO set DD=%%c
 +for /f "​tokens=1-4 delims=/ " %%a in ("​%date%"​) DO set YY=%%d
 +for /f "​tokens=1-3 delims=: " %%a in ("​%time%"​) do set HH=%%a
 +for /f "​tokens=1-3 delims=: " %%a in ("​%time%"​) do set MI=%%b
 +set LOGNAME=BUILD_%MM%%DD%%YY%_%HH%%MI%.log
 +echo Logfile : %LOGNAME%
 +Beyond this if you are compiling something which needs to go into %LOGNAME%, you use the >> redirection operator
 +ccompile myfile.c >> %LOGNAME% 2>&1
 +  * [[BatFiles|Back to Batch Files]]
batlogdate.txt ยท Last modified: 2014/10/25 21:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0