How to copy subdirectories of multiple un-named directories
Posted
by Scrubbie
on Stack Overflow
See other posts from Stack Overflow
or by Scrubbie
Published on 2010-05-06T22:33:21Z
Indexed on
2010/05/06
22:38 UTC
Read the original article
Hit count: 243
ant
Using just Ant, I want to copy subdirectories of some top-level directories but the names of top-level directories can change so I need Ant to programatically determine which directories to copy.
In other words, given the sample directory structure below, copy the contents of each ./<projectX>/bin
directory to ./bin
.
bin
project1
\-- bin
\-- com
\-- name
\-- dir1
\-- file1.class
\-- file2.class
\-- file3.class
\-- dir2
\-- file4.class
\-- file5.class
project2
\-- bin
\-- com
\-- name
\-- dir3
\-- file6.class
\-- file7.class
\-- file8.class
project3
\-- bin
\-- com
\-- name
\-- dir4
\-- file9.class
\-- dir5
\-- file10.class
\-- file11.class
And the end result would be a bin directory that looks like this:
bin
\-- com
\-- name
\-- dir1
\-- file1.class
\-- file2.class
\-- file3.class
\-- dir2
\-- file4.class
\-- file5.class
\-- dir3
\-- file6.class
\-- file7.class
\-- file8.class
\-- dir4
\-- file9.class
\-- dir5
\-- file10.class
\-- file11.class
I've tried
<copy todir="${basedir}/bin">
<fileset dir="${basedir}">
<include name="**/bin/*"/>
<exclude name="bin"/>
</fileset>
</copy>
but that includes the projectX/bin
directories underneath the top-level bin directory.
© Stack Overflow or respective owner