K:\bin>type get_date_without_space.bat
SET DATE_WITH_SPACE=%DATE%
FOR /F "TOKENS=1-2" %I IN ("%DATE_WITH_SPACE%") DO SET DATE_WITHOUT_SPACE=%I_%J
ECHO %DATE_WITHOUT_SPACE%
This doesn't work. Why?
K:\bin>get_date_without_space.bat
K:\bin>SET DATE_WITH_SPACE=Fri 11/16/2018
DATE_WITH_SPACEI_J was unexpected at this time.
K:\bin>FOR /F "TOKENS=1-2" DATE_WITH_SPACEI_J
K:\bin>
Echo %date: =_%
%%I
and%%J
See ss64.com/nt/for.htmlfor /?
and read it's output