Solved

Delete files older then a certain date from a folder

Posted on 2004-09-29
4
330 Views
Last Modified: 2008-01-09
I would like to automatically delete files from a certain folder that are older then a week old(for example) by using a batch file.
My OS is windows XP but I would also like to use it in windows 2000.

Is this possible and if so how
0
Comment
Question by:dbdp
  • 3
4 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 12177947
Tip Top - Asked this very question and I was answered (excellently) here
http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20956707.html
0
 
LVL 23

Accepted Solution

by:
Danny Child earned 500 total points
ID: 12181304
for a less scripty solution, try the FORFILES.EXE server resource kit tool
http://www.jsiinc.com/SUBL/tip5600/rh5645.htm

example:
FORFILES -pc:\foldername -s -m*.* -d-7 -c"CMD /C del @FILE"

-p = path
-s = include subdirs
-m = match filetype
-d = age in days (can also be set as an absolute date ie DDMMYYYY) note that - or + can be used here
-c = command to execute

there's also a -v Verbose switch
note, no spaces between the switches and their qualifiers above!
0
 
LVL 23

Expert Comment

by:Danny Child
ID: 12183599
you can get the file here
http://www.dynawell.com/reskit/microsoft/win2000/forfiles.zip

sheduled task to run the script should do it nicely!
0
 
LVL 23

Expert Comment

by:Danny Child
ID: 12225520
dbdp - hows it going with all this?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now