Avatar of thandel

asked on 

How do delete a folder after X days old

Using Windows XP, I have the following batch file:

@echo off

SET month=%DATE:~4,2%
SET day=%DATE:~7,2%
SET year=%DATE:~-4%
SET hour=%time:~0,2%
SET sec=%time:~3,2%
SET millis=%time:~6,2%

set folder=%year%_%month%%day%_%hour%%sec%

rem remove spaces from single digit values
set folder=%folder: =%

mkdir %folder%


This makes a folder based and named based on date and time.  This folder will later be populated for backup purposes.  Of course this can get rather large so I would like to also add to the batch to check for any folders X days old and then delete those folders.

Is this possible?

Thank you
Windows XP

Avatar of undefined
Last Comment

8/22/2022 - Mon