ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: Reg:Selection of files on the basis of timestamp
Date Mon, 17 Aug 2009 15:15:37 GMT
On Mon, Aug 17, 2009 at 10:25 AM, S G <tc1915@yahoo.com> wrote:

> Hi,
>     I have a folder which has files of different extension.
>     I have to select files on the basis of timestamp.
> For eg : 5 days old.
> How to do this?
> Thanks & Regards
> Sulabh



Have you looked at this section: <
http://ant.apache.org/manual/CoreTypes/selectors.html>?
This will tell you how to use <date> to select files just as you would with
<include> and <exclude> selectors.

And the <TStamp> task: <http://ant.apache.org/manual/CoreTasks/tstamp.html>?
The <date> selector needs an actual date. You can use <Tstamp> to calculate
the date via the "offset" attribute.

You can do something like this:

<!-- Sets for five days before -->
<Tstamp property="start.date"
    offset="-5"
    unit="day"
    pattern="MM/DD/YYYY"/>

<!-- Sets for six days before -->
<Tstamp property="end.date"
    offset="-6"
    unit="day"
    pattern="MM/DD/YYYY"/>

<!--Tries to select between five and six days before -->
<fileset dir="${my.dir}">
    <date datetime="${start.date} 12:01 AM" when="before"/>
    <date datetime="${end.date} 11:59 PM" when="after"/>
</fileset>

-- 
David Weintraub
qazwart@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message