tags:

views:

664

answers:

3

I need to copy all files in a folder except directory in that folder using Ant script.

Im using below script to do that.

<copy todir="targetsir">
  <fileset dir="srcdir">
     <include name="**/*.*"/>
  </fileset>
</copy>

But it copies all files and directory in that folder.

how to restrict/filter directory in that folder?

thanks,

+2  A: 

Do you mean that srcdir conatins sub-directories, and you you don't want to copy them, you just want to copy the files one level beneath srcdir?

<copy todir="targetsir">
  <fileset dir="srcdir">
     <include name="*"/>
  </fileset>
</copy>

That should work. The "**/*.*" in your question means "every file under every sub directory". Just using "*" will just match the files under srcdir, not subdirectories.

skaffman
thanks, Its working.
Srinivasan
A: 

Can you try

<copy todir="targetsir"> 
  <fileset dir="srcdir"> 
     <include name="*.*"/> 
  </fileset> 
</copy>

** is used to match a directory structure.

Rahul
A: 

how to copy all the files from sub directory and not the folders

Rahul