Skip to content

Instantly share code, notes, and snippets.

@xgenvn
Last active August 26, 2017 12:53
Show Gist options
  • Save xgenvn/1123786cee313875b3270304bbb86200 to your computer and use it in GitHub Desktop.
Save xgenvn/1123786cee313875b3270304bbb86200 to your computer and use it in GitHub Desktop.
Get Date from DOS
@echo on
:: GENERATE UNIQUE
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('"echo.|date"') do (
for /f "tokens=1-3 delims=/.- " %%A in ("%date:* =%") do (
set %%a=%%A&set %%b=%%B&set %%c=%%C))
set /a "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100"
for /f "tokens=1-4 delims=:. " %%A in ("%time: =0%") do @set UNIQUE=%yy%%mm%%dd%%%A%%B%%C%%D
:: DONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment