Solved

Delete files older then a certain date from a folder

Posted on 2004-09-29
4
331 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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