Skip to content
Home » Windows » Create a Date Folder on Windows

Create a Date Folder on Windows

For categorizing daily backup files, we should make folders named with that date. In this post, we'll talk about how to create a folder by current date.

Check Date Variables

First of all, we open a command prompt (CMD), and then we print the date variables before actually create it.

C:\Users\Administrator>echo "%date:~10,4%%date:~4,2%%date:~7,2%"
"20230616"

It looks good.

Create Date Folder

We use mkdir to make it.

C:\Users\Administrator>mkdir "C:\Backup\%date:~10,4%%date:~4,2%%date:~7,2%"

We see no error.

Switch Date Folder

We can make a test to switch present working directory to the new folder.

C:\Users\Administrator>cd "C:\Backup\%date:~10,4%%date:~4,2%%date:~7,2%"

C:\Backup\20230616>

We made it.

To automatically run the command, you may put the command into your batch file.

Leave a Reply

Your email address will not be published. Required fields are marked *