如何使用 ant 将 zip 文件的顶级文件夹展平? [英] How do I flatten the top level folder of a zip file with ant?

查看:31
本文介绍了如何使用 ant 将 zip 文件的顶级文件夹展平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多 zip 文件都有一个根文件夹,如何解压 zip 文件并去掉根文件夹?

A lot of zip files have a root folder, how do I unpack the zip file and get rid of the root folder?

我知道有globmapper:

<unzip dest="${dest.path}">
    <fileset dir="${source.path}">
        <include name="**/zipfile*.*.zip" />
    </fileset>
    <mapper>
        <globmapper from="rootFolder/*" to="*" />
    </mapper>
</unzip>

但是如果我不知道根文件夹的名称怎么办?通配符不起作用,例如

But what if I don't know the name of the root folder? Wildcards are not working e.g.

<globmapper from="root*Folder/*" to="*" />

有没有办法使用通配符或映射器/函数在没有根文件夹的情况下进行打包?

Is there a way to use wildcards or a mapper/function that upacks without the root folder?

推荐答案

实际上有一个单独的映射器专门为此设计,称为 cutdirsmapper.试试这个:

There's actually a separate mapper specifically made for this called cutdirsmapper. Give this a try:

<unzip dest="${dest.path}">
    <fileset dir="${source.path}">
        <include name="**/zipfile*.*.zip" />
    </fileset>
    <cutdirsmapper dirs="1" />
</unzip>

这篇关于如何使用 ant 将 zip 文件的顶级文件夹展平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆