質問

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

I know there is the 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?

役に立ちましたか?

解決

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>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top