PC Review


Reply
Thread Tools Rate Thread

delete files older than X date

 
 
Scott Closter
Guest
Posts: n/a
 
      21st Apr 2004
Is there a command line utility (delete does not seem to
have this function) where you can specify to delete files
older than a specied number of days?
 
Reply With Quote
 
 
 
 
Paul R. Sadowski
Guest
Posts: n/a
 
      21st Apr 2004

"Scott Closter" <(E-Mail Removed)> wrote in message
news:21e301c427ae$b4b3c6d0$(E-Mail Removed)...
> Is there a command line utility (delete does not seem to
> have this function) where you can specify to delete files
> older than a specied number of days?


You could do it with robocopy if you have it from the resource kit.
SOmething like this:

md %temp%\12345del
robocopy d:\stuff %temp%\12345del /s /mov /minage:10
rd /q /s %temp%\12345del

minage represents the minimum age in days to delete. 10 days or older in the
example above.

/s means move the files from subdirs as well.

/mov moves and deletes the source files. /move moves and deletes both files
and directories.

In summary, you are moving files x days and older to a temp dir. then
deleting the temp dir.

robocopy source destination /s /mov /minage:x

There are probably dedicated progs and batch solutions to do this but this
is nice and simple. robocopy is free in the 2003 server resource lit
(downloadable) and people say it works on 2K as well.


 
Reply With Quote
 
Phil Robyn
Guest
Posts: n/a
 
      21st Apr 2004
Scott Closter wrote:
> Is there a command line utility (delete does not seem to
> have this function) where you can specify to delete files
> older than a specied number of days?


Download the free program FORFILES.EXE from ftp://ftp.microsoft.com/ResKit/y2kfix/x86/

--
Phil Robyn
Univ. of California, Berkeley

u n z i p m y a d d r e s s t o s e n d e - m a i l
 
Reply With Quote
 
Scott Closter
Guest
Posts: n/a
 
      21st Apr 2004
Hi Paul, that would work indeed. I have been using
robocopy for other purposes, so I think that would easily
work for what I need. Thanks.
>-----Original Message-----
>
>"Scott Closter" <(E-Mail Removed)> wrote in

message
>news:21e301c427ae$b4b3c6d0$(E-Mail Removed)...
>> Is there a command line utility (delete does not seem to
>> have this function) where you can specify to delete

files
>> older than a specied number of days?

>
>You could do it with robocopy if you have it from the

resource kit.
>SOmething like this:
>
>md %temp%\12345del
>robocopy d:\stuff %temp%\12345del /s /mov /minage:10
>rd /q /s %temp%\12345del
>
>minage represents the minimum age in days to delete. 10

days or older in the
>example above.
>
>/s means move the files from subdirs as well.
>
>/mov moves and deletes the source files. /move moves and

deletes both files
>and directories.
>
>In summary, you are moving files x days and older to a

temp dir. then
>deleting the temp dir.
>
>robocopy source destination /s /mov /minage:x
>
>There are probably dedicated progs and batch solutions to

do this but this
>is nice and simple. robocopy is free in the 2003 server

resource lit
>(downloadable) and people say it works on 2K as well.
>
>
>.
>

 
Reply With Quote
 
Olaf Engelke [MVP]
Guest
Posts: n/a
 
      27th Apr 2004
Phil Robyn wrote:
> Scott Closter wrote:
>> Is there a command line utility (delete does not seem to
>> have this function) where you can specify to delete files
>> older than a specied number of days?

>
> Download the free program FORFILES.EXE from
> ftp://ftp.microsoft.com/ResKit/y2kfix/x86/


The syntax for deleting the files would be:

forfiles.exe -p C:\Test -m *.* -d-X -c "cmd /c del @FILE"

Instead of X use your X+1 as value.
If you need to include hidden files, add /a, for files in subfolders /s to
the DEL command.
(Tested on Windows Server 2003).

Best greetings from Germany
Olaf.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Script Delete File Older 1 Wk Date Modified =?Utf-8?B?Sm9lIEsu?= Windows XP Performance 0 12th Jun 2006 07:38 PM
Cannot delete files older than a specific date Dougbert Microsoft Outlook 5 11th Apr 2006 02:21 PM
Cannot delete files older than a specific date Dougbert Microsoft Outlook Discussion 5 11th Apr 2006 02:21 PM
rule in Outlook 2003 to delete messages older than a certain date =?Utf-8?B?UmljaGFyZEdvc2xpbmc=?= Microsoft Outlook Discussion 5 9th Apr 2006 10:40 AM
Re: delete files older than specified date Torgeir Bakken (MVP) Microsoft Windows 2000 0 10th Sep 2003 10:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:34 PM.