user1797693
user1797693

Reputation:

Ant + start copying from one folder inside the source directory

I have a source directory with the following structure.

D:\Files\temporaryname\my_files_to_be_copied

The directory name "temporaryname" may vary from time to time. I need an ant script to copy the files "my_file_to_be_copied" to some other destination.

Simply I need to go one folder inside the source directory and start copying all. Please assist. Thanks in advance.

Upvotes: 0

Views: 32

Answers (1)

Mark O'Connor
Mark O'Connor

Reputation: 77971

Lots of ways to do this here's one example, demonstrating filesets and mappers.

Example

├── build.xml
├── build
│   └── destination
│       ├── file1.txt
│       ├── file2.txt
│       ├── file3.txt
│       └── file4.txt
└── src
    ├── dir1
    │   └── my_files_to_be_copied
    │       ├── file1.txt
    │       └── file2.txt
    └── dir2
        └── my_files_to_be_copied
            ├── file3.txt
            └── file4.txt

build.xml

<project name="demo" default="copy">

   <target name="copy" description="Copy files">
      <copy todir="build/destination">
         <fileset dir="src" includes="**/my_files_to_be_copied/**"/>
         <cutdirsmapper dirs="2"/>
      </copy>
   </target>

   <target name="clean" description="Additionally purge ivy cache">
      <delete dir="build"/>
   </target>

</project>

Upvotes: 1

Related Questions