如何使用/ f而不是if

时间:2012-11-21 22:17:36

标签: cmd dos

我不知道我的for / f是多么合适。请有人帮忙。我需要使用for / f而不是所有的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

1 个答案:

答案 0 :(得分: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%