Reputation: 5642
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.
Upvotes: 2
Views: 1762
Reputation: 253
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>
Upvotes: 0
Reputation: 5642
<copy todir="folderB">
<fileset dir="folderA/">
<include name="file*" />
</fileset>
</copy>
This works. Note the trailing slash in dir="folderA/".
Upvotes: 2