?
Solved

Delete files older then a certain date from a folder

Posted on 2004-09-29
4
Medium Priority
?
338 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

850 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