Utility to delete folders from x days

G

Guest

Hi All,

Does anyone know if there is any utility or script I can use to delete
folders in X number of days?

For example: These folders are automatically created based on date.

20051013
20051014
20051015
20051016
20051017
..
..
etc..


Thannks,

Steve
 
J

Jerold Schulman

Hi All,

Does anyone know if there is any utility or script I can use to delete
folders in X number of days?

For example: These folders are automatically created based on date.

20051013
20051014
20051015
20051016
20051017
.
.
etc..


Thannks,

Steve


See tip 9828 » How can I retrieve the current year, month, day, hour, minutes, second, GMT offset, and Daylight Saving Time flag?
in the 'Tips & Tricks' at http://www.jsifaq.com

See tip 0721 » General purpose date math routine.

@echo off
if {%2}=={} @echo DelDtFldr X FldrPath&goto :EOF
if %1 NEQ +%1 @echo DelDtFldr X FldrPath&goto :EOF
if not exist %2 @echo DelDtFldr X FldrPath&goto :EOF
setlocal
set /a X=10000%1%%10000
set fldr=%2#
set fldr=%fldr:"=%
set fldr=%fldr:\#=%
set fldr=%fldr:#=%
Call DateTime YYYY MM DD HH MN SS oGMT DST
Call JSIDateM %YYYY% %MM% %DD% - %X%
for /f "Tokens=*" %%a in ('dir /b /ad "%fldr%"') do (
if "%%a" LEQ "%AYMD%" @echo RD /s /q "%fldr%\%%a"
)
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top