Last active
August 29, 2015 14:07
-
-
Save renekreijveld/cbb7045dc37e788512be to your computer and use it in GitHub Desktop.
Create a date-time stamp in Windows batch file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
for /f "tokens=1-8 delims=.:/-, " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do ( | |
for /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do ( | |
set dow=%%i | |
set mm=%%j | |
set dd=%%k | |
set yy=%%l | |
set hh=%%m | |
set min=%%n | |
set sec=%%o | |
set hsec=%%p | |
) | |
) | |
if %hh%==0 set hh=00 | |
if %hh%==1 set hh=01 | |
if %hh%==2 set hh=02 | |
if %hh%==3 set hh=03 | |
if %hh%==4 set hh=04 | |
if %hh%==5 set hh=05 | |
if %hh%==6 set hh=06 | |
if %hh%==7 set hh=07 | |
if %hh%==8 set hh=08 | |
if %hh%==9 set hh=09 | |
set timeStamp=%yy%%mm%%dd%-%hh%%min%%sec% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment