Ant copy with different basedir

ant

Given the directory structure:

root
    build.xml
    folderA
        file1
        file2
    folderB
        file3

I'm trying to copy the files in folderA into folderB, when I try, it ends up putting folderA in folderB so I end up with:

folderB
    folderA
        file1
        file2
    file3

I just want the files copied across with the same structure so I end up with:

folderB
    file1
    file2
    file3

My Ant task looks like this:

<copy todir="folderB">
    <fileset dir="folderA">
        <include name="file*" />
    </fileset>
</copy>

Any hints?

edit: I can't use flatten as there is a directory structure beneath folderA that needs to be preserved.

Best Answer

<copy todir="folderB">
    <fileset dir="folderA/">
        <include name="file*" />
    </fileset>
</copy>

This works. Note the trailing slash in dir="folderA/".

Related Topic