curtisupshall
curtisupshall

Reputation: 396

Batch: Create a Folder and Name it by Today's Date

How can I make a batch file that will create a folder (in a specified directory) that will create a folder and label it with today's date? Can I also make it delete folders that are one week old or older?

Upvotes: 0

Views: 491

Answers (2)

mihai_mandis
mihai_mandis

Reputation: 1658

Please see this post how to get data value independent of data/Time format (zone): batch file to copy some files and changing their name

Upvotes: 0

Ken White
Ken White

Reputation: 125651

One question at a time. Addressing your first one:

cd \YourSpecificDirectory
SET Today=%Date:~10,4%%Date:~4,2%%Date:~7,2%
REN Creates folder in format 20050812  (depending on regional settings and language)
md %Today%

Answers to your second question (how to delete a folder before a certain date) already exist here. A search should find them for you pretty easily.

Upvotes: 3

Related Questions