Code:
@Echo Off
If "%Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _NumTok=2-4)
For /F "Tokens=%_NumTok% Delims=./- " %%f In ("%date%") Do Set _Today=%%f/%%g/%%h
)
Echo %_Today%
Added the line in Red and also added a space after Delims.
This will get the date regarless of your Regional settings, and sets the _fdate variable to YYYYMMDD. You can then extract the year, month, and day from _fdate and put it together anyway you want:
Code:
@Echo Off
Set _Date=%date%
If "%_Date%A" LSS "A" (Set _NumTok=1-3) Else (Set _NumTok=2-4)
:: Default Delimiter of TAB and Space are used
For /F "TOKENS=2*" %%A In ('REG QUERY "HKCU\Control Panel\International" /v iDate') Do Set _iDate=%%B
For /F "TOKENS=2*" %%A In ('REG QUERY "HKCU\Control Panel\International" /v sDate') Do Set _sDate=%%B
IF %_iDate%==0 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%_Date%") Do Set _fdate=%%D%%B%%C
IF %_iDate%==1 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%_Date%") Do Set _fdate=%%D%%C%%B
IF %_iDate%==2 For /F "TOKENS=%_NumTok% DELIMS=%_sDate% " %%B In ("%_Date%") Do Set _fdate=%%B%%C%%D
Set _Today=%_fdate:~4,2%-%_fdate:~6,2%-%_fdate:~0,4%
Echo %_Today%
HTH
Jerry