Differences

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

Link to this comparison view

batlogdate [2014/10/26 01: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%
 +</​code>​
 +
 +Beyond this if you are compiling something which needs to go into %LOGNAME%, you use the >> redirection operator
 +
 +<​code>​
 +ccompile myfile.c >> %LOGNAME% 2>&1
 +</​code>​
 +
 +----
 +
 +  * [[BatFiles|Back to Batch Files]]
  
batlogdate.txt ยท Last modified: 2014/10/26 01: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