You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eric Jain <Er...@isb-sib.ch> on 2003/05/02 10:29:31 UTC

Testing for File.lastModified > 1d

Is there a task or combination of tasks that allows you to set a
variable to true, if a specified file is older than e.g. one day?

--
Eric Jain


Re: Testing for File.lastModified > 1d

Posted by Eric Jain <Er...@isb-sib.ch>.
Excellent, thanks a lot!


> What about:
> <project default="day.old.test">
>   <target name="day.old.test">
>     <property name="my.file" value="build.xml"/>
>     <tstamp>
>       <format
>         property="day.old.time"
>         pattern="MM/dd/yyyy hh:mm aa"
>         offset="-1" unit="day"
>       />
>     </tstamp>
> 
>     <touch file=".my_day_old_file" datetime="${day.old.time}"/>
>     <uptodate property="my.file.is.old"
>               targetfile=".my_day_old_file"
>               srcfile="${my.file}"/>
>     <echo message="${my.file.is.old}"/>
>   </target>
> </project>


--
Eric Jain


Re: Testing for File.lastModified > 1d

Posted by peter reilly <pe...@corvil.com>.
What about:
<project default="day.old.test">
  <target name="day.old.test">
    <property name="my.file" value="build.xml"/>
    <tstamp>
      <format
        property="day.old.time"
        pattern="MM/dd/yyyy hh:mm aa"
        offset="-1" unit="day"
      />
    </tstamp>

    <touch file=".my_day_old_file" datetime="${day.old.time}"/>
    <uptodate property="my.file.is.old"
              targetfile=".my_day_old_file"
              srcfile="${my.file}"/>
    <echo message="${my.file.is.old}"/>
  </target>
</project>


On Friday 02 May 2003 12:41, Eric Jain wrote:
> > Is there a task or combination of tasks that allows you to set a
> > variable to true, if a specified file is older than e.g. one day?
>
> The following is about the closest I get. It might even work,
> unfortunately ${taxonomy.path} contains an absolute file name and
> therefore can't be put into a fileset, it seems...
>
>
>   <target name="taxonomy.verify">
>
>     <tstamp>
>       <format
>         property="oldest.time"
>         pattern="MM/dd/yyyy hh:mm aa"
>         offset="-1" unit="day"
>       />
>     </tstamp>
>
>     <delete>
>       <fileset dir="/" includes="${taxonomy.path}">
>         <date when="before" datetime="${oldest.time}"/>
>       </fileset>
>     </delete>
>
>     <available
>       property="taxonomy.skip"
>       file="${taxonomy.path}"
>     />
>
>   </target>


Re: Testing for File.lastModified > 1d

Posted by Eric Jain <Er...@isb-sib.ch>.
> Is there a task or combination of tasks that allows you to set a
> variable to true, if a specified file is older than e.g. one day?

The following is about the closest I get. It might even work,
unfortunately ${taxonomy.path} contains an absolute file name and
therefore can't be put into a fileset, it seems...


  <target name="taxonomy.verify">

    <tstamp>
      <format
        property="oldest.time"
        pattern="MM/dd/yyyy hh:mm aa"
        offset="-1" unit="day"
      />
    </tstamp>

    <delete>
      <fileset dir="/" includes="${taxonomy.path}">
        <date when="before" datetime="${oldest.time}"/>
      </fileset>
    </delete>

    <available
      property="taxonomy.skip"
      file="${taxonomy.path}"
    />

  </target>


--
Eric Jain