蚂蚁解压缩后父目录 [英] Ant Zip Extracted Parent Directory
问题描述
我有我需要一个Ant目标中的几个解压缩zip文件。所有zip文件都在同一个目录下,有相同的内部目录和文件结构。
I have several zip files that I need to unzip within an Ant target. All the zip files are in the same directory, and have the same internal directory and file structure.
所以我用下面的代码片段解压缩目录中的所有压缩文件,但每一个zip文件不包含在根父文件夹,所以每个连续的压缩文件解压缩,并覆盖previous文件。
So I am using the following snippet to unzip all the zip files in the directory, but each zip file does not contain a parent folder at the root, so each successive zip file is unzipped and overwrites the previous files.
<unzip dest="C:/Program Files/Samsung/Samsung TV Apps SDK/Apps">
<fileset dir=".">
<include name="**/*.zip"/>
</fileset>
</unzip>
有没有更好的方式来解压一组文件,并创建一个目录来解压缩它们是基于zip文件名?
Is there a better way to unzip a group of files, and create a directory to unzip them to that is based on the zip file name?
因此,如果zip文件是:
So, if the zip files are:
1.zip
2.zip
3.zip
那么每个的内容将被提取到:
then the content of each will be extracted to:
1/
2/
3/
感谢
推荐答案
一个解决办法可能是使用的蚂蚁的contrib '的'和'propertyregex任务要做到这一点:
One solution might be to use the ant-contrib 'for' and 'propertyregex' tasks to do this:
<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文件
扩展为目标目录名来使用。
The 'propertyregex' strips the .zip
extension from the zip file name to use as the target directory name.
这篇关于蚂蚁解压缩后父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!