here is what I have so far but not being an expert don't know where to go from here
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set WD=%%i
)
for /f "tokens=1-2 delims=," %%a in ("Sat,Sun") do if not %%a==%WD% Echo %WD%
here is what I have so far but not being an expert don't know where to go from here
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set WD=%%i
)
for /f "tokens=1-2 delims=," %%a in ("Sat,Sun") do if not %%a==%WD% Echo %WD%
The tokens
keyword extracts one or more tokens from a text file line or string based on a delimiter, and assigns them to alphabetically subsequent variables, once per line, and you only need the first token on the line. Using a space as the delimiter breaks the date (returned by date /t
as "Wed 11/01/2017") after the day of week. Use the set
command to assign the value to an environment variable, WD
.
for /F "tokens=1 delims= " %%i in ('date /t') do set WD=%%i
Testing in batch files is done by if
with environment variable expansion delimited by %
around the environment variable. Matches are literal, so quotes must be placed around the variable value and the match value.
On Sunday, don't do anything so exit the batch file with exit /b
.
if "%WD%" == "Sun" exit /b
On Saturday, run the Saturday task and the rest of the week, run the weekday task.
if "%WD%" == "Sat" (
rem do Sat
) else (
rem do Mon-Fri
)