Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5943249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:22:05+00:00 2026-05-22T16:22:05+00:00

My question is in continuation of this thread: Ant: copy the same fileset to

  • 0

My question is in continuation of this thread:
Ant: copy the same fileset to multiple places

I am new to mappers. Can someone (carej?) kindly share an example of using the mapper to do this ? Here is what I am trying for:

parent_folder
    |----child1_folder
    |         |----files
    |                |----config.file
    |                |----data.txt
    |----child2_folder
    |----child3_folder
    .
    .
    .
    |----childn_folder

I don’t have the option to use ant-contrib (sorry … the ant location or any taskdesf isn’t under my control). So I don’t know how to loop over the uncertain number of folders.

Restrictions on me:

  1. I only know the name of child1_folder (don’t know names of the other children)
  2. Number of other children is uncertain
  3. I am expected to create the files folder under each child folder (via another task, if not copy).

Here is what I was trying for (currently trying for a single file, will extend with additional mappers once this starts to work):

<copy todir="/tmp/parent_folder" verbose="true">
    <fileset dir="/tmp/parent_folder">
        <include name="*/files/config.file"/>
    </fileset>
    <mapper type="glob" from="*/files/config.file" to="*/files/config.file"/>
</copy>

It keeps saying skipped - don't know how to handle it followed by No sources found..

Thanks in advance,
Parag Doke

Another (possibly?) related question:
Using mapper & fileset to copy files into a different subdirectory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:22:06+00:00Added an answer on May 22, 2026 at 4:22 pm

    Here’s an example of one way. The key features are the use of enablemultiplemappings in the copy task, and a scriptmapper to deal with iterating over the target directories. A mapper chain is used to make the source that is provided to the scriptmapper be just the path of the file to be copied relative to the target directory.

    <property name="src.dir" value="child1_folder" />
    
    <dirset dir="parent_folder" id="target.dirs">
        <include name="*" />
        <exclude name="${src.dir}" />
    </dirset>
    
    <copy todir="parent_folder" enablemultiplemappings="yes">
        <fileset dir="parent_folder">
            <include name="${src.dir}/**"/>
        </fileset>
        <chainedmapper>
            <globmapper from="${src.dir}/*" to="*" />
            <scriptmapper language="javascript">
            <![CDATA[
                // Obtain a reference to the dirset
                var dirSet = project.getReference( "target.dirs" );
    
                // Now get matching dirs.
                var ds = dirSet.getDirectoryScanner( project );
                var includes = ds.getIncludedDirectories( );
                for ( var i = 0; i < includes.length; i++ )
                {
                    self.addMappedName( includes[i] + "/" + source );
                }
            ]]>
            </scriptmapper>
        </chainedmapper>
    </copy>
    

    Mulitple mappings in the copy task have been in Ant since version 1.6.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is a continuation of this thread : In short: To solve my
This question is a continuation of a previous thread to compare two lists with
This question is in continuation to my existing thread . Below given is a
This is a continuation of the this question. I am new to network programming,
As a continuation of this question I'm wondering if I can get some simple
This is a continuation of this question: Original Question (SO) The answer to this
This question is a continuation of my previous question here zend models architecture (big
This question is in continuation to my previous question . I am trying to
I guess this is a continuation of the last question I asked: bulk insert
Ok - this is in continuation from my earlier question about sending an email

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.