1

I dont know how right my for /f is. Please somebody help. I need to use the for /f instead of all the IF.

for /f "eol=; tokens=1,2,3* delims," %%i in (January,February,March,April,May,June,July,August,September,October,November,December) do if day7=%%i && set month12=%%j &&

set day365=%%k
set day7=%DATE:~0,3%
set month12=%DATE:~4,2% 
set day365=%DATE:~7,2%
set year1=%DATE:~10,4%

if /i %day7%==Sun set day7=Sunday
if /i %day7%==Mon set day7=Monday
if /i %day7%==Tue set day7=Tuesday
if /i %day7%==Wed set day7=Wednesday
if /i %day7%==Thu set day7=Thursday
if /i %day7%==Fri set day7=Friday
if /i %day7%==Sat set day7=Saturday



if /i %month12%==1 set month12=January
if /i %month12%==2 set month12=February
if /i %month12%==3 set month12=March
if /i %month12%==4 set month12=April
if /i %month12%==5 set month12=May
if /i %month12%==6 set month12=June
if /i %month12%==7 set month12=July
if /i %month12%==8 set month12=August
if /i %month12%==9 set month12=September
if /i %month12%==10 set month12=October
if /i %month12%==11 set month12=November
if /i %month12%==12 set month12=December
4

1 回答 1

0

因此,为了将来帮助其他人,这就是它的目的。

set day7=%DATE:~0,3%
set month12=%DATE:~4,2% 
set day365=%DATE:~7,2%
set year1=%DATE:~10,4%

if %day7%==Sun set day7=Sunday
if %day7%==Mon set day7=Monday
if %day7%==Tue set day7=Tuesday
if %day7%==Wed set day7=Wednesday
if %day7%==Thu set day7=Thursday
if %day7%==Fri set day7=Friday
if %day7%==Sat set day7=Saturday

for /f "eol=; tokens=%month12% delims=," %%i in ("January,February,March,April,May,June,July,August,September,October,November,December") do set month12=%%i 


echo Today is %day7% %month12% %day365% %year1%
于 2012-11-29T04:09:28.150 回答