使用Ant来基于另一个文件的存在来删除文件

问题描述

我需要编写一个ant任务来有选择地删除文件。 在目录中,我有以下jar: acme.jar acme-201105251330.jar 我要删除acme.jar,因为存在acme-*。jar。 这是我尝试过的:
<target name=\"-check-use-file\">
<available property=\"file.exists\"> 
<filepath> <fileset dir=\".\"> 
  <include name=\"./test-*.jar\"/> </fileset> 
</filepath> 
</available> 
</target> 
<target name=\"use-file\" depends=\"-check-use-file\" if=\"file.exists\"> 
<!-- do something requiring that file... --> 
</target>
谢谢     

解决方法

看一下If / Unless属性,给出的示例似乎正是您要寻找的。