You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Ciramella, Edward" <EC...@emptoris.com> on 2003/02/07 23:11:08 UTC

selector

I want to write a target to delete all items that are after a particular
date.

Before I roll this out, I wanted to test my functionality in the following
manner:
-create a file
-sleep 2 min
-create a file
-sleep 2 min
-create a file
-sleep 2 min
-create a file

-take a timestamp
-delete all files older than timestamp -2 min

every time I run this it deletes all my files vs just the ones that are
currenttime-2min old.

What am I missing?

<target name="build">
     <touch file="myfile-1.txt"/>
 <sleep minutes="2"/>
     <touch file="myfile-2.txt"/>
 <sleep minutes="2"/>
     <touch file="myfile-3.txt"/>
 <sleep minutes="2"/>
     <touch file="myfile-4.txt"/>
 <tstamp>
     <format property="bld.date" pattern="MM/DD/yyyy hh:mm a" locale="en"
offset="-2 unit="minute"/>
 </tstamp>

 <echo message="${bld.date}"/>
   <delete>
     <fileset dir="." includes="**/*.txt"> 
	<date datetime="${bld.date}" when="before"/>
     </fileset>
  </delete>

</target>