Computing Staff
  • 0

Batch Script To Return If Today Is First Weekday Of Month

  • 0

I need a batch script that runs a specific process if the current weekday is the first weekday of the current month, else run a separate batch script if it’s anything else. Does anyone have something that does this already?

Share

1 Answer

  1. This only works if your date format is like “Sat 03/10/” (year doesn’t matter). If not, you might want to use vbscript for date-handling. Batch is fickle about dates.
    ::===== begin batchscript “weakday”
    @echo off & setlocal
    rem for testing purposes: set /p dd=date:
    set dd=%date%
    set z=%dd:~0,1%
    set proc=xx.bat
    set aa=01
    if /i %z% equ s set aa=00
    if /i %z% equ m set aa=03
    if “%dd:~7,2%” leq “%aa%” set proc=zz.bat
    echo calling %proc%
    call %proc%
    ::===== end batch

    • 0