hello i got a batch file, something like this:
if %day%==monday, tuesday, wednesday, thursday, friday (
goto yes
) else (
goto no
)
Now i know the first line won't work.
What i actually want to happen:
It automatticly checks which day it is. If it is Monday to Friday, it has to go to 'yes', otherwise (saturday/sunday) to 'no'.
How to do this?
Here is an example bat file that will do this sort of thing I am sure you can think of other ways to use this sample code. For instance anytime you need an "in" list. The tricky bit is the %date:~0,3% this says expand the %date% environment variable and starting at position 0 the beginning of the string return the next 3 characters. You can learn more about this from the "set /?" command.
example: IsWeekDay.bat
@echo off
setlocal
for %%i in (Mon,Tue,Wed,Thu,Fri) do (
if "%date:~0,3%"=="%%i" goto YES
)
:NO
echo No
goto EOF
:YES
echo Yes
:EOF
endlocal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With