Listing 1: Using UNIX's Date.exe to Write Hourly Log Files @echo off goto Start :Start call :logIt Log this line to the log file. goto :EOF :logIt call :getTimestamp set logFile=test.%prefix%.log >>%logFile% echo %timestamp%: %* USER: %username% APPLICATION: %~f0 goto :EOF :getTimeStamp BEGIN COMMENT :: Replace the path with your path to date.exe. :: The Windows For /F command requires :: that you use only 8.3 short filename notation. :: Avoid a space between %%j and & set prefix; :: otherwise, you'll unintentionally append a space :: to the timestamp. END COMMENT for /f "tokens=1,2,3*" %%i in ('c:\tools\etc\date.exe +"%%y-%%m-%%d %%H:%%M:%%S %%Y%%m%%d%%H"') do set timestamp=%%i %%j& set prefix=%%k goto :EOF BEGIN COMMENT :: The previous command could also be written as :: for /f "tokens=1,2,3*" %%i in ('c:\tools\etc\date.exe :: +"%%y-%%m-%%d :: %%H:%%M:%%S %%Y%%m%%d%%H"') do ( :: set timestamp=%%i %%j :: set prefix=%%k :: ) END COMMENT :EOF