@echo off REM Get useful date out of Windows, using UNIX date REM v1.0 sometime in 2001 or 2002 REM This requires a UNIX date command. I use the UNXUTILs, which are awesome. REM http://unxutils.sourceforge.net/ REM You probably want to put the date command in your path, and rename it so REM that it does not interfere with the Windows data command. REM udate.exe is a good name. REM Set a local scope for the following variables setlocal for /f "tokens=1" %%x in ('udate +%%Y-%%m-%%d-%%H:%%M:%%S') do set DateTime=%%x echo. echo. echo You could now do something like this: echo copy mylog %%DateTime%%-mylog echo copy mylog %DateTime%-mylog echo. echo. for /f "tokens=1" %%x in ('udate +%%Y%%m%%d%%H%%M%%S') do set DateTime=%%x echo. echo Or this: %DateTime% echo. for /f "tokens=1" %%x in ('udate ++%%Y-%%m-%%dT%%H:%%M:%%S%%z') do set DateTime=%%x echo. echo Or this (ISO8601): %DateTime% echo. echo. echo Or just do this for a display or a log file entry: echo. echo udate "+%0 Starting at %%c..." udate "+%0 Starting at %%c..." echo. echo udate "+%0 Starting at %%x %%X..." udate "+%0 Starting at %%x %%X..." echo. REM End the local scope for variables endlocal