2014-07-16 31 views
1

Higuys。使用ANT將目錄中所有文件的「修改」時間更改爲其他目錄中文件的「修改」時間

我有一個小問題,ant touch任務。 我需要做的:

我有一個源代碼目錄:從中

C:\development\source\project\staticfiles\cartridge\rules\*.drl

,並將所有文件複製到 '目標' 目錄:

C:\development\target\project\release\rules\*.drl

由於它們是使用ant進行復制的,因此'target'目錄中新創建文件的'修改'時間會分別更改,但我需要從'source'目錄更改爲'modified'時間相應文件他們被複制後。換句話說,我需要兩個文件的「修改」時間相同。

我想ant touch可以幫助在這裏,但我不知道如何同時處理兩個目錄。

謝謝你的幫助。

回答

2

您可以使用<copy>任務的preservelastmodified屬性。

preservelastmodified : Give the copied files the same last modified time as the original source files.

如。

<copy todir="${dest.dir}" preservelastmodified="true"> 
    <fileset dir="${src_dir}"/> 
</copy> 
相關問題