Delete files older than X days

  • Thread starter Thread starter babu
  • Start date Start date
B

babu

Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Can anyone let me know whether its a bug or thats the way
forfiles works..

Thanks & appreciate ur help

BAbu
 
babu said:
Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Can anyone let me know whether its a bug or thats the way
forfiles works..

Thanks & appreciate ur help

BAbu

That is *not* the way FORFILES works. You probably are not
using the right command syntax, or else you don't have the
latest version of FORFILES.
 
babu said:
Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Perhaps you can post what you are using. Could it be that you need to quote
the filename like below?
C:\Users\Sadowski [(firecat) 16:08, Tue 06/29/2004]
forfiles -pc:\temp\captures -mcapture*.* -d-2 -c"cmd /c echo
""@PATH\@FILE"""
"c:\temp\captures\Capture3-18-2004-2.02.28 AM.gif"
"c:\temp\captures\Capture6-23-2004-5.32.03 PM.jpg"
"c:\temp\captures\Capture6-24-2004-1.34.14 PM.jpg"
 
babu said:
Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Can anyone let me know whether its a bug or thats the way
forfiles works..
Hi

In the article below there is a WSH script (vbscript) by Michael Harris
that deletes files x days old in a specific folder (and optionally all
subfolders).

Newsgroups: microsoft.public.scripting.wsh
Date: 2002-10-07 08:12:33 PST
http://groups.google.com/[email protected]



WSH 5.6 documentation (local help file) can be downloaded from
here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Can anyone let me know whether its a bug or thats the way
forfiles works..

Thanks & appreciate ur help

BAbu
DELOLD freeware at tip 274 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Can you let me know the best way to use it.. below is my
code to delete files older than 4 days

forfiles -pc:\test -d-4 -c"CMD /C DEL /Q ""@PATH\@FILE""

Babu
-----Original Message-----
Can you let me know..how to delete files older than X
days in Windows 2000 server only..
[snip]

Using 4NT, this command will delete files older than 7 days:
DEL /[d-7,1980/1/1]

I use this regularly to delete old log files and such.

4NT's date ranges are documented at
<http://jpsoft.com/help/dateranges.htm>
 
Can you let me know the best way to use it.. below is my
code to delete files older than 4 days. I need to delete
test and subdirtory files older tahn 4 day.

Below is the code

forfiles -pc:\test -S -m*.bak -d-4 -c"CMD /C
DEL /Q ""@PATH\@FILE""

Thanks & apprecaite ur help


Babu
-----Original Message-----

babu said:
Can you let me know..how to delete files older than X
days in Windows 2000 server only..

I tried using forfiles.. but it doesn't have flexibilty
that it can't accept filename more than 8.

Perhaps you can post what you are using. Could it be that you need to quote
the filename like below?
C:\Users\Sadowski [(firecat) 16:08, Tue 06/29/2004]
forfiles -pc:\temp\captures -mcapture*.* -d-2 -c"cmd /c echo
""@PATH\@FILE"""
"c:\temp\captures\Capture3-18-2004-2.02.28 AM.gif"
"c:\temp\captures\Capture6-23-2004-5.32.03 PM.jpg"
"c:\temp\captures\Capture6-24-2004-1.34.14 PM.jpg"


.
 
I think I have written a VBScript application that does what you want and a bit more :) The code is zipped up and can be downloaded via the linked to page!

http://www.code-bytes.com/Automate_WSH_VBScript_To_Delete_Or_Archive_Files.html
http://www.code-bytes.com/Automate_WSH_VBScript_To_Delete_Or_Archive_Files.html


* The code that I have allows you to Delete and/or archive files by specifying ...
1.)directory to be searched
2.) age of the file
3.) Use regular expressions to allow for pattern matching file names.


The script is highly configurable and creates a log of actions taken on files matching your criteria.


If you find the code useful/helpful/or a waste of time then please let me know. All feed back and requests for enhancements welcome!


The code is free, but if it really helps you please feel free to donate:)
 
Back
Top