-----Original Message-----
From: yousufhaider [mailto:yousuf.r...@gmail.com]
Sent: Tuesday, January 20, 2009 11:11 PM
To: user@ant.apache.org
Subject: Copy files in a directory not directory itself where source directory 
name is not known

/*

[...]

Basically what I want to is to copy everything under source/repository-**/
and place it in target.

The problem is that when I do this:

<copy todir="target">
  <fileset dir="source">
    <include name="repository-**/**"/>
  </fileset>
</copy>

it ends up creating a directory structure like this:

target
       repository-TIMESTAMP
                  /file1
                  /file2
                  /folder1
                         /file3

I want it to not copy the repository folder.

*/

try with =

<!-- // Properties -->
<property name="copysrc" value="C:/source" />
<property name="copytarget" value="C:/target" />
<!-- Properties // -->

<target name="main">

<!-- get name of the repository folder ... -->
<dirset dir="${copysrc}" includes="repos*" id="reposdir" />

<copy todir="${copytarget}" overwrite="true" verbose="true">
  <!-- and take the reposdir as root of your fileset -->
  <fileset dir="${copysrc}/${toString:reposdir}" includes="**/**" />
</copy>

</target>


gives you =

[copy] Copying 4 files to C:\target
     [copy] Copying C:\source\repository-Timestamp\file2\foobar.txt to 
C:\target\file2\foobar.txt
     [copy] Copying C:\source\repository-Timestamp\file1\foo.txt to 
C:\target\file1\foo.txt
     [copy] Copying C:\source\repository-Timestamp\folder1\file3\fooo.txt to 
C:\target\folder1\file3\fooo.txt
     [copy] Copying C:\source\repository-Timestamp\folder1\foobaz.txt to 
C:\target\folder1\foobaz.txt



Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to