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?
Asked
Active
Viewed 463 times
2 Answers
3
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.
-
+1 Clarified that the folder format with the code above is not fixed, as the %date% variable changes with region and language and user preferences. – foxidrive Nov 21 '13 at 04:46
0
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

Community
- 1
- 1

mihai_mandis
- 1,578
- 1
- 10
- 13