使用ant查找和使用最新的修改后的文件夹/目录 [英] Finding and using the latest modified FOLDER/Directory using ant

查看:138
本文介绍了使用ant查找和使用最新的修改后的文件夹/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当前的解决方案是我在所有文件夹中找到最新的修改后的FILE.我需要一种方法来获取最新的修改后的文件夹.原因是,每天都会创建一个文件夹,我将需要在文件路径中使用该文件夹值,以便可以将该路径的内容复制到另一个目录中.

So the current solution I have finds the latest modified FILE inside all of the folders. I need a way to get the latest modified folder. The reason being, a folder will get created on a daily basis, and I will need to use that folder value in a file path so that I can copy the contents of that path in another directory.

我的代码如下:

<target name = "latest">
 <copy todir = "H:\New">
  <last>
   <sort>
    <date xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
    <filseset dir ="H:\test"/>
   </sort>
  </last>
 </copy>
</target>

Folder Overview
Main
|---Folder2(16/01/15)
|---Folder1(28/01/15)

程序需要选择Folder1(总体思路).

The program needs to select Folder1 (overall idea).

I.E.文件路径:C:/A/$ {latest.modified<}/etc/files

I.E. of file path: C:/A/${latest.modified<}/etc/files

推荐答案

要查找目录而不是文件,请使用

To find a directory rather than a file, use a <dirset> instead of a <fileset>, for example:

<last id="last.dir">
    <sort>
        <dirset dir="H:\test" includes="*" />
        <date />
    </sort>
</last>
<echo message="${ant.refid:last.dir}" />

这篇关于使用ant查找和使用最新的修改后的文件夹/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆