我有几个 zip 文件需要在 Ant 目标中解压缩。所有 zip 文件都位于同一目录中,并且具有相同的内部目录和文件结构。
因此,我使用以下代码片段来解压缩目录中的所有 zip 文件,但每个 zip 文件在根目录下不包含父文件夹,因此每个连续的 zip 文件都会解压缩并覆盖以前的文件。
<unzip dest="C:/Program Files/Samsung/Samsung TV Apps SDK/Apps">
<fileset dir=".">
<include name="**/*.zip"/>
</fileset>
</unzip>
有没有更好的方法来解压缩一组文件,并根据 zip 文件名创建一个目录来将它们解压到该目录?
因此,如果 zip 文件是:
1.zip
2.zip
3.zip
然后每个内容将被提取为:
1/
2/
3/
Thanks
一种解决方案可能是使用蚂蚁贡献 http://ant-contrib.sourceforge.net/tasks/tasks/index.html'for' 和 'propertyregex' 任务来执行此操作:
<for param="my.zip">
<fileset dir="." includes="**/*.zip" />
<sequential>
<propertyregex property="my.zip.dir"
input="@{my.zip}"
regexp="(.*)\..*"
select="\1"
override="yes" />
<unzip src="@{my.zip}" dest="${my.zip.dir}" />
</sequential>
</for>
'propertyregex' 剥离了.zip
zip 文件名的扩展名用作目标目录名。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)