Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: How to select the latest modified file from a directory?

Tags:

ant

Assume I have a directory which contains several files with the same name prefix and a timestamp, e.g.

my-directory:
- file-0749
- file-1253
- file-2304

How can I tell ANT to select the latest modified file from my directory (in this case this would be file-2304)?

like image 967
Peter Avatar asked Mar 31 '11 10:03

Peter


1 Answers

You can do that with the TimestampSelector task from ant-contrib.

<timestampselector property="latest.modified">
  <path>
    <fileset dir="${my-directory.dir}">
      <include name="file-*" />
    </fileset>
  </path>
</timestampselector>

<echo message="${latest.modified}" />
like image 173
Lesmana Avatar answered Dec 03 '22 00:12

Lesmana