|
Answer» Hi there,
I'm trying to write a script that deletes directories older than 10 days but also keeps the most recent (7) folders. I can't seem to find the right mix of commands for this ONE... Any help?
THANK youWhat do you have so far ? ?I think I sort of fixed my script, SEEMS to do what I want... Not exactly as I described, but it fits
Code: [Select]for/f "tokens=*" %%G IN ('dir \\server\data\ /b /AD ^| find "" /v /N /c ') DO set value=%%G if %value% LSS 14 goto dontdelete
for /f "tokens=* skip=14" %%a in ('dir \\server\data\ /A:D /O-D /B ') do set deldir=%%a rmdir /s /q "\\server\data\%deldir%"
:dontdelete
|