Computing.Net > Forums > Programming > Batch Script Help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Script Help

Reply to Message Icon

Name: Dany75
Date: April 16, 2009 at 18:44:04 Pacific
OS: Windows 2000
Subcategory: Batch
Comment:

hello,

I have a folder that I want to periodiclly clean out old folders. For example a folder is created every day that looks like 04162009. I want to keep the last 60 folders and delete any folder dated before that. I am just getting started using the SET and FOR commands and need a little help getting this one going on Win 2000.

Thank in advance,



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: April 16, 2009 at 22:29:09 Pacific
Reply:

if you change your folder pattern to yyyymmdd, it would be easier to manage IMO.
for /f "skip=60" %%a in ('dir/b/o-n/ad 200*') do echo delete this %%a

otherwise, you might check out dir switch /od /tw /tc, however with this method i think it can lead to incorrect result.

or you could parse the mmddyyyy folder name


0

Response Number 2
Name: Dany75
Date: April 20, 2009 at 19:33:32 Pacific
Reply:

Thanks for the reply! It gives me a good idea of what to do.

FOR /F "skip=60 delims=" %%a IN ('DIR /O-D /B /AD') DO RD /S /Q "%%a"

Thanks again!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Script Help

Batch Script Help Needed www.computing.net/answers/programming/batch-script-help-needed/14475.html

Simple Batch Script help www.computing.net/answers/programming/simple-batch-script-help/12744.html

Batch Script Help and Suggestions www.computing.net/answers/programming/batch-script-help-and-suggestions/14552.html