ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Delete all but the most recent N files
Date Wed, 09 Oct 2002 21:50:47 GMT
You could achieve *almost* what you want I think using the <date> selector,
but it only takes an absolute date instead of a relative one. Writing a
different selector that takes a relative date should be easy.

Doing exactly what you want with a selector seems impossible, since
selectors need to decide for every single file whether to include it or not,
and in your case you need to know the most N recent files to include only
those (you would need *global* selectors, or two passes...).

It's a shame I think, because writing a custom task for this specific job is
fine, but as a selector, it can be used with any task that takes a fileset,
which makes it much more powerful. --DD

-----Original Message-----
From: Richard Dallaway [mailto:richard@dallaway.com] 
Sent: Wednesday, October 09, 2002 4:06 PM
To: Ant Users List
Subject: Delete all but the most recent N files

I'm looking for a task that will allow me to delete a set of files, 
except for the last N (say, the last 5 most recently modified files).

Specifically, the application I work on is built automatically (using 
Cruse Control), and I'd like to keep just the last N .jar files that it 
constructs -- rather than have to remember to go and clean up the 
directory when the disk fills :-(.

I guess I could do this with a cron job/scheduled task, or I could shell 
out, but I think it would be neater as a task.  I'm very happy to go and 
write a custom task, but I'd rather not if there's a clever way to do 
this using the core or optionals tasks.

Many thanks
Richard



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message