troubleshooting Question

Batch File - do a backup of file that is the last business day of the month

Avatar of Endri Azizi
Endri Azizi asked on
Microsoft DOSWindows Batch
9 Comments1 Solution756 ViewsLast Modified:
Hi there!
I am new with batch scripting does anyone can help me,
I have to backup the last file only and only if is the last business day of th month using batch script

Thanks a lot.

business days
not business days
@echo off

setlocal enabledelayedexpansion
:: *** Get the current date into the variables dd, mm, yy:
set day = %date%
echo %date%
for /f "tokens=1-3 delims=/" %%a in ("%date%") do (
  set dd=%%a
  set mm=%%b
  set yy=%%c
set Feb=28
set /a Leap=yy %% 4
if "%Leap%"=="0" set Feb=29
set i=101
for %%a in (31 %Feb% 31 30 31 30 31 31 ott34 31 35 31) do (
  set /a i+=1
  if !i!==1%mm% set LastDay=%%a
echo This month's last Day: [%LastDay%]
if %dd%==%LastDay% echo Today is the last day of this month.

echo ***** start business day script *****


echo 0=Sunday - 1=Monday - 2=Tuesday - 3=Wednesday - 4=Thursday - 5=Friday - 6=Saturday

for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do set %%x
set day=%DayOfWeek%
echo ***** number day: %DayOfWeek% *****

set result=false

IF "%day%"=="6" set result=true
IF "%day%"=="0" set result=true

IF "%result%" == "true" (
    ECHO ***** is not a business day *****
) ELSE (
    ECHO ***** business day %LastDay% *****

REM if %dd%==%LastDay% call fri.bat

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros