Solved Batch Script To Delete Oldest Folder With A Specific Name

Dell / Pe2950
October 12, 2012 at 05:19:14
Specs: Server 2003 R2, Dual Xeon 5150
I spent a little time on this one a can't seem to find exactly what I need. I don't have anything to offer because I'm truly stumped. I have 3 folders named like this:

Rox
Rox07122011
Rox09302012

These folders reside in a directory with many other folders. Via a batch script I want to be able to delete the "Rox" folder (and only the "Rox" folder) in this directory with the oldest Modified date but I don't know how to do it.

Please tell me how to do this.

Thank you,

MJ


See More: Batch Script To Delete Oldest Folder With A Specific Name

Report •

#1
October 12, 2012 at 18:24:33
✔ Best Answer
@for /f "tokens=*" %%a in ('dir /o:d /b /a:d rox*') do ECHO rd /s /q %%a & goto :eof
::===== end script

safety is ON. remove 'ECHO' to switch the safety OFF. This will show you what it "intends" to do before something gets hosed.


Report •
Related Solutions


Ask Question