Windows 11: Generate 52 Work Week Folders Given Year using Notepad++ .bat File
In this article, we will explain how to generate 52 work week folders for a given year using a simple .bat file in Notepad++ on Windows 11. This method can be helpful for organizing your files and folders by weeks in a year. We will cover the key concepts, provide detailed instructions, and include code blocks to help you understand and implement this technique.
Prerequisites
Before you begin, make sure you have the following:
- A Windows 11 system
- Notepad++ installed
Key Concepts
A .bat file, short for batch file, is a type of script file in Windows. It contains a series of commands to be executed by the command interpreter. In our case, the .bat file will create 52 folders, one for each week in a year.
Generating the .bat File
To create a .bat file for generating work week folders, follow these steps:
- Open Notepad++
- Enter the following code, replacing "Year:" with your desired year:
@echo off
setlocal enabledelayedexpansion
for /L %%w in (1,1,52) do (
set "week=WEEK!%%w!"
for /F "skip=5 delims=/" %%d in ('date /t') do (
set "day=%%d"
)
if "!day:~0,1!" lss "9" (
set "day=0!day!"
)
if "!week!" == "WEEK1" (
set "startday=30"
set "endday=5"
) else if "!week!" == "WEEK52" (
set "startday=29"
set "endday=31"
) else (
set /a "startday+=7"
set /a "endday+=7"
)
if "!startday!" lss "10" (
set "startday=0!startday!"
)
if "!endday!" lss "10" (
set "endday=0!endday!"
)
md "!week! %day:~0,2%-!startday!-!endday!"
)
pause
Here's a breakdown of the code:
@echo off: Prevents the command prompt from displaying each command before it is executedsetlocal enabledelayedexpansion: Allows the use of delayed expansion of variablesfor /L %%w in (1,1,52): Iterates through 52 weekly incrementsfor /F "skip=5 delims=/" %%d in ('date /t') do: Skips the first 5 lines of the 'date /t' output and separates the day from the date stringif "!day:~0,1!" lss "9": Adds a leading zero if the day is a single digitmd "!week! %day:~0,2%-!startday!-!endday!": Creates a folder for the current week using a naming format of "WEEK <week number> <two-digit day>-<start day>-<end day>"
Using the .bat File
To generate the work week folders for your chosen year, follow these steps:
- Save the Notepad++ file as "GenerateWeekFolders.bat"
- Right-click the .bat file and select "Run as administrator"
- Enter the desired year in the following format: "Year: 2025" and press Enter
- Wait for the process to complete, and press any key to exit the command prompt
You should now have 52 work week folders for the given year.
- Using Notepad++ on Windows 11, you can create a .bat file to generate 52 work week folders for a given year
- The provided code uses command prompt commands and variables to create the folders in the desired format
- Running the .bat file as an administrator with the desired year input will generate the week ```vbnet folders