【问题标题】:Finding and using the latest modified FOLDER/Directory using ant使用ant查找和使用最新修改的FOLDER/Directory
【发布时间】:2015-03-28 19:11:03
【问题描述】:

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

我的代码如下:

<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(整体思路)。

I.E.文件路径:C:/A/${latest.modified

【问题讨论】:

    标签: xml ant build directory


    【解决方案1】:

    要查找目录而不是文件,请使用&lt;dirset&gt; 而不是&lt;fileset&gt;,例如:

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

    【讨论】:

    • 你是上帝派来的!非常感谢
    猜你喜欢
    • 2019-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多