tags:

views:

703

answers:

2

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.

+1  A: 
<copy todir="folderB">
    <fileset dir="folderA/">
        <include name="file*" />
    </fileset>
</copy>

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

Cogsy
A: 

You are actually really close just need to create the directory first if you want to maintain the folder structure after copy.

<target name="copy">
    <mkdir dir="folderB/folderA"/>
    <copy todir="folderB/folderA">
        <fileset dir="folderA"/>
    </copy>
</target>
Matt Campbell
This shouldn't matter. Copy will create any directories that are needed.
Eddie