Home > Software engineering >  BATCH FILE - create folders with every WORKING DAY (no saturday and sunday)
BATCH FILE - create folders with every WORKING DAY (no saturday and sunday)

Time:12-07

I would like to edit the following batch code in order to create a folder with every working day of the year and skip saturday and sunday (i guess it should create 5 consecutive days and skip the next 2) I would also like the batch file to

  1. skip creating folders for each month(a january folder, a february folder etc) and have all days of the year in the same folder.
  2. add two extra folders in each day folder with 'morning' and 'afternoon'

Ex:

C:\Users\alex\Desktop\2022\1 Jan\Morning
C:\Users\alex\Desktop\2022\1 Jan\Afternoon

all the way to

C:\Users\alex\Desktop\2022\31 Dec\Morning
C:\Users\alex\Desktop\2022\31 Dec\Afternoon

(it would not create 31 dec folder because thats a saturday)

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "sourcedir=U:\years"
SET /p year=### Enter Year [e.g. 2014]:
IF NOT DEFINED year GOTO :EOF 
SET year=%year:,=%
IF %year% lss 100 SET /a year=2000 year
IF %year% gtr 1901 IF %year% lss 2099 GOTO generate
ECHO year entered out of range 1901..2099
GOTO :eof

:generate
MD "%sourcedir%"
SET /a feb=year %% 4
IF            
  • Related