Question: Can anyone help me debug / correct this batch file? :: Extract components from the date and time for / f tokens = 1 -
Can anyone help me debugcorrect this batch file?
:: Extract components from the date and time
for f "tokens delimsa in date t do
:: Store day of week
set dayOfWeeka
:: Store month
set monthb
:: Store the day
set dayc
:: Store the year
set yeard
for f "tokens delims:x in time t do
:: Store the hour
set hourx
:: Store the minutes
set minutey
:: Get letter day name
set daydate:~
:: Create map for letter name to full name
set mapMonMonday;TueTuesday;WedWednesday;ThuThursday;FriFriday;SatSaturday;SunSunday
call set daymap:day
:: Convert letter name to full name
set dayday:;&rem.
:: Get the month number
set monthNamedate:~
:: Create map for month number to full month name
set mapJanuary;February;March;April;May;June;July;August;September;October;November;December
call set monthNamemap:monthName
:: Convert the month number to the full month name
set monthNamemonthName:;&rem.
:: Convert hour format to hour format and determine period of the day
set A "hourModhour
if hourMod geq
set periodPM
if hourMod gtr
set A hourMod
else
set periodAM
:: Handle h format midnight :
if hourMod set hourMod
:: Determine morning, afternoon, or evening
if hour lss
set timeOfDaymorning
else if hour lss
set timeOfDayafternoon
else
set timeOfDayevening
:: Display the message
echo Hello username
echo Today's date is dayOfWeekmonthdayyear
echo It is currently hourMod:minuteperiod
echo.
echo Today is day and it is monthNamedayyear
echo Have a wonderful timeOfDay
It currently works, however the message displayed at the end of the script says both am and pm simultaneously, and always says have a wonderful morning regardless of the time of day it's executed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
