-1
Q
文件的蚂蚁年龄
A
回答
1
马克的链接并没有解决我的问题,但给我的主意,用脚本
<!-- Check if specified file is newer than age in seconds -->
<scriptdef name="isNewerThan" uri="composer.ant.mleko" language="javascript">
<attribute name="file"/> <!-- The file to check. -->
<attribute name="age"/> <!-- The threshold of file age in seconds. -->
<attribute name="property"/> <!-- The name of property to set. -->
<attribute name="value"/> <!-- The value to set the property to. Defaults to "true". -->
<attribute name="else"/> <!-- The value to set the property to if the condition evaluates to false. By default the property will remain unset. -->
<![CDATA[
var fileName = attributes.get("file");
var age = attributes.get("age");
var property = attributes.get("property");
var value = attributes.get("value");
var elseValue = attributes.get("else");
var maxAge = parseInt(age, 10);
if(null === fileName)self.fail("`file` is required");
if(null === age || isNaN(maxAge))self.fail("`age` is required and must be valid int string");
if(null === property)self.fail("`property` is required");
if(null === value)value="true";
var file = new java.io.File(fileName);
var ageInSeconds = (Date.now() - file.lastModified())/1000;
if(ageInSeconds < maxAge){
project.setProperty(property, value);
}else if(null !== elseValue){
project.setProperty(property, elseValue);
}
]]>
</scriptdef>
0
要与<tstamp>
使用<touch>
和<uptodate>
在一起:
<tstamp>
<format property="one.week.ago" offset="-7" unit="day" pattern="MM/dd/yyyy hh:mm aa"/>
</tstamp>
<touch file="source-file.txt" datetime="${one.week.ago}"/>
<uptodate
property="target-file-modified-in-previous-week"
targetfile="target-file.txt"
>
<srcfiles dir= "." includes="source-file.txt"/>
</uptodate>
<condition property="is-target-file-out-of-date" value="true" else="false">
<isset property="target-file-modified-in-previous-week"/>
</condition>
<echo>is-target-file-out-of-date: ${is-target-file-out-of-date}</echo>
的[Linux的删除文件夹比老
相关问题
- 1. 蚂蚁的jar文件
- 2. 问题的蚂蚁文件
- 3. 蚂蚁排除文件
- 4. 蚂蚁副本文件夹
- 5. 蚂蚁,(过)写入文件
- 6. 蚂蚁复制文件
- 7. 蚂蚁:一个文件夹
- 8. 使apk文件与蚂蚁
- 9. 蚂蚁:我如何在interate所有子文件夹和蚂蚁
- 10. Java中的文件年龄
- 11. 重建蚂蚁的grails war文件
- 12. 每个文件相关的蚂蚁
- 13. 带蚂蚁的文件枚举
- 14. 蚂蚁:将类名的文件路径
- 15. 删除年龄大于特定年龄的文件夹
- 16. Winston文件传输年龄
- 17. 文件年龄报告
- 18. 文件集蚂蚁,包括外部源?
- 19. 蚂蚁replaceTokens行号和文件名
- 20. 蚂蚁忽略复制任务文件?
- 21. 蚂蚁部署到jar文件
- 22. 蚂蚁basedir和eclipse .project文件生成
- 23. 蚂蚁没有执行.exe文件
- 24. 蚂蚁replacetoken与多个jar文件名
- 25. 蚂蚁regexpmapper文件分隔符发出
- 26. 蚀几个蚂蚁生成文件
- 27. 蚂蚁 - 从zip文件中导入jar
- 28. 用蚂蚁创建构建文件
- 29. 蚂蚁非递归文件集
- 30. 蚂蚁复制任务忽略文件
可能重复1年和超过3个文件](http://stackoverflow.com/questions/11531631/linux-removing-folders-older-than-1-year-and-more-than-3-files) – 2014-12-27 20:49:13