Setting day,month and year variables in Windows batch

@echo off&SETLOCAL
FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :FIXDATE %%G %%H %%I %%J)
goto :SETDATE
:FIXDATE
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
    set %%G=%1&set %%H=%2&set %%I=%3)
goto :eof
:SETDATE
ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%

Comments

Popular posts from this blog