title: Copy newest file with filename filter in Ant
body: <p>I'm trying to copy the newest file from a directory using Ant, ideally I'd like to have a filter on the filename too (eg: '*file.java'), but I don't have any idea of how to do this</p>
  
  <p>I've included my script so far, but it's breaking in the JavaScript and I've not got enough experience to know why.</p>
  
  <pre><code>&lt;project name="test1" basedir="."&gt;
  
      &lt;property file="../local.properties" /&gt;
      &lt;property file="../build.properties" /&gt;
      &lt;property file="../default.properties" /&gt;
  
      &lt;target name="init"&gt;        
          &lt;copy todir="."&gt;
              &lt;fileset dir="/path/to/files"&gt;
                  &lt;scriptselector language="javascript"&gt;
                      var files = basedir.list();
                      var mostRecent = true;
                      for(var i = 0; i &lt; files.size(); i++) {
                          mostRecent = mostRecent &amp;&amp; (filename &gt;= files[i]);
                      }
                      self.setSelected(mostRecent);
                  &lt;/scriptselector&gt;
              &lt;/fileset&gt;
          &lt;/copy&gt;
      &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>edit: just realised the site i got the above JavaScript code from states that this selector is "to select only the newest file of a directory where each file has a time stamp as its filename" so my example won't work because it's using the name as the modified date.  This leads to the question of how to get the modified date of a file in JavaScript (or any other language which works with Ant)</p>