-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. 排除螞蟻的文件
- 2. 螞蟻的jar文件
- 3. 問題的螞蟻文件
- 4. 螞蟻xmltask文件拷貝
- 5. 螞蟻排除文件
- 6. 螞蟻:一個文件夾
- 7. 螞蟻複製文件
- 8. 螞蟻副本文件夾
- 9. 螞蟻,(過)寫入文件
- 10. 使apk文件與螞蟻
- 11. 螞蟻:我如何在interate所有子文件夾和螞蟻
- 12. 螞蟻條件塊
- 13. Java中的文件年齡
- 14. 螞蟻
- 15. 螞蟻
- 16. 每個文件相關的螞蟻
- 17. 帶螞蟻的文件枚舉
- 18. 重建螞蟻的grails war文件
- 19. 螞蟻:將類名的文件路徑
- 20. 複製與螞蟻最近的文件
- 21. 螞蟻的build.xml清單文件讀取
- 22. 螞蟻覆蓋我的manifest.mf文件
- 23. 刪除年齡大於特定年齡的文件夾
- 24. Winston文件傳輸年齡
- 25. 文件年齡報告
- 26. 螞蟻 - 添加文件到zip
- 27. 排序文件集數字在螞蟻
- 28. 獲取螞蟻運行java文件
- 29. jrxml文件不使用螞蟻編譯
- 30. 比較xml文件與Maven或螞蟻
可能重複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