In this tutorial, I will explain how to create folders using PowerShell that are dynamically named based on the current year, month, and day. This can be incredibly useful for organizing files and folders by date. I recently needed to implement this myself to keep track of daily reports at my company, located in Seattle.
Create Folders with Year, Month, and Day Using PowerShell
To create a folder with the current date in PowerShell, we can use the Get-Date cmdlet and New-Item cmdlet. Here’s a simple example:
$folderName = Get-Date -Format "yyyy-MM-dd"
New-Item -ItemType Directory -Path "C:\Reports\$folderName"This script does the following:
- Gets the current date and formats it as “yyyy-MM-dd” (e.g. “2025-03-31”)
- Creates a new folder with that date as the name in the “C:\Reports” directory
To break it down further:
Get-Date -Format "yyyy-MM-dd"retrieves the current date and formats it in the specified format.New-Item -ItemType Directorycreates a new directory (folder)-Pathspecifies the full path where the folder should be created, referencing the$folderNamevariable
The path in the above command will work in the Windows OS.
I am using a macOS, and you can provide the path like below:
$folderName = Get-Date -Format "yyyy-MM-dd"
New-Item -ItemType Directory -Path "/Users/bijay/Downloads/$folderName"I executed the above PowerShell script, and you can see the exact output in the screenshot below:

Check out Create a Folder with the Current Date using PowerShell
Create Year and Month Subfolders Using PowerShell
In my case, I needed to organize the folders further by year and month. To accomplish this, we can tweak the script to:
- Create a folder for the current year if it doesn’t exist
- Create a subfolder in the year folder for the current month if it doesn’t exist
- Create the dated folder inside the month folder
Here’s the modified PowerShell script:
$year = Get-Date -Format "yyyy"
$month = Get-Date -Format "MM"
$day = Get-Date -Format "dd"
$basePath = "C:\Reports"
$yearPath = Join-Path $basePath $year
$monthPath = Join-Path $yearPath $month
New-Item -ItemType Directory -Path $yearPath -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $monthPath -ErrorAction SilentlyContinue
$folderName = "{0}-{1}-{2}" -f $year,$month,$day
$folderPath = Join-Path $monthPath $folderName
New-Item -ItemType Directory -Path $folderPathThis will generate a folder structure like:
C:\Reports\
2025\
03\
2025-03-31\A few notes on the updated script:
- We retrieve the year, month, and day components separately using
Get-Datefor more flexibility Join-Pathis used to build the full paths by combining the base path, year, month, and day-ErrorAction SilentlyContinuesuppresses errors if the directory already exists- The folder name is constructed using the
-fstring format operator to avoid long concatenations
Read Create Files with Content Using PowerShell
Running the Script Daily
We can schedule the PowerShell script to run daily using Task Scheduler on Windows to fully automate the process. Here are the high-level steps:
- Save the script with a
.ps1extension (e.g.CreateDatedFolder.ps1) - Open Task Scheduler and create a new task
- Configure the task with the following settings:
- Run whether the user is logged in or not
- Trigger: Daily at a specified time
- Action: Start a program
- Program/script:
powershell.exe - Arguments:
-File "C:\path\to\CreateDatedFolder.ps1"
- Program/script:
- Save the task
Now the script will automatically run each day and create the appropriate year, month, and day folders to keep your files organized chronologically.
Conclusion
In this tutorial, I explained how to create folders with Year, Month, and Day using PowerShell. By using the Get-Date cmdlet to retrieve the current year, month, and day, you can generate a clean folder structure that makes it easy to manage files on a daily basis.
You may also like:
- Get All Files in a Directory Using PowerShell
- List Directories in PowerShell
- Create a File in the Current Directory Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.