給定一個帶有未知目錄的zip文件,如何重命名或將該目錄移動到規範化路徑?使用ant,在不知道完整路徑的情況下重命名目錄?
<!-- Going to fetch some stuff -->
<target name="get.remote">
<!-- Get the zipfile -->
<get src="http://myhost.com/package.zip"
dest="package.zip"/>
<!-- Unzip the file -->
<unzip src="package.zip"
dest="./"/>
<!-- Now there is a package-3d28djh3 directory. The part after package- is
a hash and cannot be known ahead of time -->
<!-- Remove the zipfile -->
<delete file="package.zip"/>
<!-- Now we need to rename "package-3d28djh3" to "package". My best attempt
is below, but it just moves package-3d28djh3 into package instead of
renaming the directory. -->
<!-- Make a new home for the contents. -->
<mkdir dir="package" />
<!-- Move the contents -->
<move todir="package/">
<fileset dir=".">
<include name="package-*/*"/>
</fileset>
</move>
</target>
我不是一個螞蟻用戶,任何洞察力都會有所幫助。
謝謝了,-Matt
搗亂工作的搗蛋。我有*不知道*邏輯流程應該在那裏......我們用dirset創建一個路徑,然後將它存儲在正確的位置,以便我們可以在移動時訪問它的字符串值。尼斯布萊恩'。 – mixonic 2010-04-06 19:34:14
Drat,當然這不適用於宏,因爲它使用屬性。 @#$ @(ant。 – mixonic 2010-04-07 12:53:13
我知道它已經2年了,而且這絕對有效,但我很想知道爲什麼這會起作用,爲什麼沒有更直觀的方法來簡單地重命名「fixed-prefix- *」目錄到「someConstantName」 – radai 2012-09-08 15:01:10