In this tutorial, I will explain how to create a folder with the current date as the name using PowerShell. This can be very useful for organizing files and automating folder creation based on dates. We will see several examples in PowerShell demonstrating different ways to accomplish this.
As an IT professional in the USA, I often need to create dated folders for projects, backups, or archiving data. For example, let’s say I’m working on a project for a client based in New York City, and I want to create folders to store daily status reports. Manually creating a new folder each day and naming it with the date would be tedious. That’s where PowerShell comes in handy to automate the process.
Now, let me show you how to use different methods.
Using the Get-Date Cmdlet
The simplest way to create a folder with the current date in PowerShell is by using the Get-Date cmdlet combined with New-Item. Here’s an example:
$folderName = Get-Date -Format "yyyy-MM-dd"
New-Item -ItemType Directory -Path "C:\Reports\$folderName"In this script:
Get-Date -Format "yyyy-MM-dd"gets the current date and formats it as “yyyy-MM-dd” (e.g. “2025-03-24”). This is stored in the$folderNamevariable.New-Item -ItemType Directorycreates a new directory (folder).-Pathspecifies the location and name for the new folder. Here, it will create a folder like “C:\Reports\2025-03-24”.
The exact output is in the screenshot below. It created a folder with today’s date in the Reports folder.

You can customize the -Format parameter to change how the date is displayed in the folder name. For instance, to include the time:
$folderName = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
New-Item -ItemType Directory -Path "C:\Logs\$folderName"This would generate a folder like “C:\Logs\2025-03-24_14-30-00”.
Check out PowerShell Copy-item Create Folder If Not Exist
Create Multiple Dated Folders in PowerShell
To create multiple folders with different dates in PowerShell, you can use a loop like ForEach. This example creates folders for the next 7 days:
$startDate = Get-Date
$numDays = 7
ForEach ($i in 1..$numDays) {
$folderDate = $startDate.AddDays($i)
$folderName = $folderDate.ToString("yyyy-MM-dd")
New-Item -ItemType Directory -Path "C:\Backups\$folderName"
}This will create folders named:
- C:\Backups\2025-03-25
- C:\Backups\2025-03-26
- C:\Backups\2025-03-27
- …
- C:\Backups\2025-03-31
I executed the above PowerShell script and you can see the exact output in the screenshot below:

Read How to Create folder if not exist in PowerShell?
Customize the Folder Path and Name in PowerShell
You can save the folder path in a variable to make it more reusable:
$basePath = "C:\Projects\Client-NYC"
$folderName = Get-Date -Format "MMddyy"
New-Item -ItemType Directory -Path "$basePath\$folderName"This creates a folder like “C:\Projects\Client-NYC\032425”.
To include other information in the folder name, just add it to the $folderName variable. For example:
$user = "jsmith"
$folderName = Get-Date -Format "yyyy-MM-dd"-UserReports-$user
New-Item -ItemType Directory -Path "C:\Reports\$folderName" Resulting folder: “C:\Reports\2025-03-24-UserReports-jsmith”
Read Create a Shortcut to a Folder Using PowerShell
Handle Errors and Existing Folders
When automating folder creation using PowerShell, it’s important to handle potential errors. One common issue is trying to create a folder that already exists. You can use Test-Path to check if the folder exists first:
$path = "D:\Archives\$(Get-Date -Format "yyyy-MM")"
if (!(Test-Path -Path $path)) {
New-Item -ItemType Directory -Path $path
} else {
Write-Host "Folder $path already exists!"
}This tries to create a folder like “D:\Archives\2025-03” for the current month. If that folder already exists, it just outputs a message instead of an error.
Check out Create a File in the Current Directory Using PowerShell
Create Folders with Date and Time in PowerShell
Sure, here’s an example of creating a folder with both the current date and time in PowerShell:
$dateTime = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$folderName = "Backup_$dateTime"
New-Item -ItemType Directory -Path "C:\Backups\$folderName"In this script:
Get-Date -Format "yyyy-MM-dd_HH-mm-ss"gets the current date and time and formats it as “yyyy-MM-dd_HH-mm-ss” (e.g. “2025-03-24_14-45-30”). This is stored in the$dateTimevariable.- The
$folderNamevariable is set to “Backup_” plus the$dateTimevalue. New-Item -ItemType Directorycreates a new folder with the path “C:\Backups$folderName”.
The resulting folder would be named something like “C:\Backups\Backup_2025-03-24_14-45-30”.
Including both the date and time in the folder name can be useful for creating multiple backups or logs in a single day. The time component allows you to distinguish between folders created on the same date.
Here are a few related points about creating folders with date and time in PowerShell:
- You can adjust the date and time format by changing the
Get-Date -Formatparameter. For example, “yyyy-MM-dd_HH-mm” would omit the seconds. - If you need to create these folders regularly, you could set up a PowerShell script to run automatically using Task Scheduler on Windows. This way, you don’t have to run the script each time manually.
- Be careful when creating many folders with date and time stamps, as it can quickly lead to a large number of folders. Make sure to clean up old folders periodically to save disk space.
For instance, to delete backup folders older than 30 days, you could use a script like this:
$backupPath = "C:\Backups"
$daysToKeep = 30
$deleteBefore = (Get-Date).AddDays(-$daysToKeep)
Get-ChildItem -Path $backupPath | Where-Object {$_.CreationTime -lt $deleteBefore} | Remove-Item -RecurseThis script:
- Gets all items in the “C:\Backups” folder
- Filters for folders created before the date 30 days ago
- Deletes those old folders using
Remove-Item -Recurse
Including both date and time in PowerShell-created folders gives you more granular organization and archiving options. Just remember to manage the number of folders created over time to avoid running out of storage space.
Conclusion
As you can see, PowerShell makes it easy to create folders with the current date in the name. This can help keep your files and projects organized. By using variables and parameters, you can customize the folder paths and names to fit your needs.
Some key points to remember:
- Use
Get-Dateto get the current date and format it New-Item -ItemType Directorycreates new folders- Combine date parts with static text and variables to build dynamic folder names
- Check if a folder already exists with
Test-Pathto avoid errors - Loops like
ForEachallow creating multiple dated folders at once
I hope this tutorial helped explain how to create dated folders using PowerShell! In the comment section below, let me know if you have any other questions.
You may also like:
- Create a File with Date in the Name Using PowerShell
- Create JSON Files with Content 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.