Day of week in batch
Posted: 23 Dec 2009, 16:20
A partire da Windows XP il formato del comando DATE non riporta il giorno della settimana.
Qui di seguito lo script per estrarre il giorno della settimana:
@echo off
echo.|command /C date|find "Current" > "%tmp%\weekday.tmp"
for /f "tokens=4" %%a in ('type "%tmp%\weekday.tmp"') do set weekday=%%a
del "%tmp%\weekday.tmp"
if %weekday%==Mon goto :mon
if %weekday%==Tue goto :tue
if %weekday%==Wed goto :wed
if %weekday%==Thu goto :thu
if %weekday%==Fri goto :fri
if %weekday%==Sat goto :sat
if %weekday%==Sun goto :sun
:SUN
exit
:MON
exit
:TUE
exit
:WED
exit
:THU
exit
:FRI
exit
:SAT
exit
Qui di seguito lo script per estrarre il giorno della settimana:
@echo off
echo.|command /C date|find "Current" > "%tmp%\weekday.tmp"
for /f "tokens=4" %%a in ('type "%tmp%\weekday.tmp"') do set weekday=%%a
del "%tmp%\weekday.tmp"
if %weekday%==Mon goto :mon
if %weekday%==Tue goto :tue
if %weekday%==Wed goto :wed
if %weekday%==Thu goto :thu
if %weekday%==Fri goto :fri
if %weekday%==Sat goto :sat
if %weekday%==Sun goto :sun
:SUN
exit
:MON
exit
:TUE
exit
:WED
exit
:THU
exit
:FRI
exit
:SAT
exit