Solved

Delete files older then a certain date from a folder

Posted on 2004-09-29
4
329 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:
DanCh99 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:DanCh99
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:DanCh99
ID: 12225520
dbdp - hows it going with all this?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

14 Experts available now in Live!

Get 1:1 Help Now