使用ant,在不知道完整路径的情况下重命名目录?
给定一个包含未知目录的 zip 文件,如何重命名该目录或将该目录移动到规范化路径?
<!-- 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>
我不是蚂蚁用户,任何见解都会有所帮助。
非常感谢,-马特
Given a zipfile with an unknown directory, how can I rename or move that directory to a normalized path?
<!-- 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>
I'm not much of an ant user, any insight would be helpful.
Thanks much, -Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当 dirset 仅返回 1 项时,此方法才有效。
This will only work as long as the dirset only returns 1 item.
如果 package-3d28djh3 目录(或解压后调用的任何名称)内没有子目录,则可以使用
否则,使用 regexp 映射器进行移动任务并删除 package-xxx 目录:
If there are no subdirectories inside the package-3d28djh3 directory (or whatever it is called once you extracted it) you can use
Otherwise, use the regexp mapper for the move task and get rid of the package-xxx directory: