You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Camer38 <re...@gmail.com> on 2007/02/13 17:29:37 UTC

Copy a single file to directories

Hi,

I would like to copy a single file to multiply directories.
Every time the structure of folders may vary.
One file has to be copy into every catalog under ./test/components

Any idea?

Thanks in advance
Marcin
-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8947606
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: AW: AW: AW: Copy a single file to directories

Posted by Camer38 <re...@gmail.com>.
Thanks.

Performance is an issue as well - in your opinion which solution is faster?

Marcin
-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8980914
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: AW: AW: Copy a single file to directories

Posted by Camer38 <re...@gmail.com>.
Hi,

I have one more chalange - pretty similar to previous one.
I need to perform a copy like in the previous example but this time I shoul
copy only in the case if a file book.xml is present othervise the copy
does't take a place.

Thanks yor any kind of tip
Marcin


Peter Reilly-2 wrote:
> 
> An example:
> 
> <project default="dirs" xmlns:ac="antlib:net.sf.antcontrib">
>   <typedef uri="antlib:net.sf.antcontrib">
>     <classpath>
>       <fileset dir="${user.home}/apps/ant-contrib" includes="*.jar"/>
>     </classpath>
>   </typedef>
> 
>   <target name="dirs">
>     <ac:shellscript shell="bash">
>       rm -rf dirs
>       mkdir -p dirs/a/org/simple
>       mkdir -p dirs/b/org/simple
>       mkdir -p dirs/d/org/simple
>       mkdir -p dirs/c/org/simple
>     </ac:shellscript>
> 
>     <ac:for param="dir">
>       <dirset dir="dirs" includes="*"/>
>       <ac:sequential>
>         <copy todir="@{dir}">
>           <fileset dir="." includes="build.xml"/>
>         </copy>
> 
>       </ac:sequential>
>     </ac:for>
>   </target>
> </project>
> 
> Peter
> 
> On 2/13/07, Camer38 <re...@gmail.com> wrote:
>>
>> Ok, let me take a deep look...
>>
>>
>> Jan.Materne wrote:
>> >
>> >>Thanks for a quick answer.
>> >>Could you be more elaborative and deliver more complex example, please.
>> >>At this moment I have a very brief idea how to use antcontrib
>> >
>> >
>> > Not without more information. Have you played with that code?
>> >
>> >
>> > Jan
>> >
>> >
>> >>
>> >>Thanks in advance - I relay appreciate you help.
>> >>
>> >>Marcin
>> >>
>> >>
>> >>Jan.Materne wrote:
>> >>>
>> >>> Quickshot ...
>> >>>
>> >>> <antcontrib:for param="todir">
>> >>>     <!-- specify the target directories -->
>> >>>     <dirset/>
>> >>>     <sequential>
>> >>>         <copy todir="@{todir}">
>> >>>             <!-- specify the files to copy -->
>> >>>             <fileset/>
>> >>>         </copy>
>> >>>     </sequential>
>> >>> </antcontrib:for>
>> >>>
>> >>>
>> >>> AFAIK there is no build-in way, so you have to iterate for your own.
>> >>>
>> >>>
>> >>> Jan
>> >>>
>> >>>
>> >>>
>> >>>>-----Ursprüngliche Nachricht-----
>> >>>>Von: Camer38 [mailto:rembiszm@gmail.com]
>> >>>>Gesendet: Dienstag, 13. Februar 2007 17:30
>> >>>>An: user@ant.apache.org
>> >>>>Betreff: Copy a single file to directories
>> >>>>
>> >>>>
>> >>>>Hi,
>> >>>>
>> >>>>I would like to copy a single file to multiply directories.
>> >>>>Every time the structure of folders may vary.
>> >>>>One file has to be copy into every catalog under ./test/components
>> >>>>
>> >>>>Any idea?
>> >>>>
>> >>>>Thanks in advance
>> >>>>Marcin
>> >>>>--
>> >>>>View this message in context:
>> >>>>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
>> >>>>51.html#a8947606
>> >>>>Sent from the Ant - Users mailing list archive at Nabble.com.
>> >>>>
>> >>>>
>> >>>>---------------------------------------------------------------------
>> >>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> >>>>For additional commands, e-mail: user-help@ant.apache.org
>> >>>>
>> >>>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> >>> For additional commands, e-mail: user-help@ant.apache.org
>> >>>
>> >>>
>> >>>
>> >>
>> >>--
>> >>View this message in context:
>> >>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
>> >>51.html#a8948408
>> >>Sent from the Ant - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >>---------------------------------------------------------------------
>> >>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> >>For additional commands, e-mail: user-help@ant.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> > For additional commands, e-mail: user-help@ant.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8948784
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8966991
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: AW: AW: Copy a single file to directories

Posted by Camer38 <re...@gmail.com>.
Hi,

Gents - hats off

Your solution is great - I like it a lot, thank you very much.

A tiny correction:

  <target name="dirs">
    <ac:for param="dir">
      <dirset dir="./test/components" includes="**"/> <-- I use ** because I
need to copy everywhere-->
      <ac:sequential>
        <copy todir="@{dir}">
          <fileset dir="." includes="test.txt"/>
        </copy>
      </ac:sequential>
    </ac:for>
  </target>


-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8960207
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: AW: AW: Copy a single file to directories

Posted by Peter Reilly <pe...@gmail.com>.
An example:

<project default="dirs" xmlns:ac="antlib:net.sf.antcontrib">
  <typedef uri="antlib:net.sf.antcontrib">
    <classpath>
      <fileset dir="${user.home}/apps/ant-contrib" includes="*.jar"/>
    </classpath>
  </typedef>

  <target name="dirs">
    <ac:shellscript shell="bash">
      rm -rf dirs
      mkdir -p dirs/a/org/simple
      mkdir -p dirs/b/org/simple
      mkdir -p dirs/d/org/simple
      mkdir -p dirs/c/org/simple
    </ac:shellscript>

    <ac:for param="dir">
      <dirset dir="dirs" includes="*"/>
      <ac:sequential>
        <copy todir="@{dir}">
          <fileset dir="." includes="build.xml"/>
        </copy>

      </ac:sequential>
    </ac:for>
  </target>
</project>

Peter

On 2/13/07, Camer38 <re...@gmail.com> wrote:
>
> Ok, let me take a deep look...
>
>
> Jan.Materne wrote:
> >
> >>Thanks for a quick answer.
> >>Could you be more elaborative and deliver more complex example, please.
> >>At this moment I have a very brief idea how to use antcontrib
> >
> >
> > Not without more information. Have you played with that code?
> >
> >
> > Jan
> >
> >
> >>
> >>Thanks in advance - I relay appreciate you help.
> >>
> >>Marcin
> >>
> >>
> >>Jan.Materne wrote:
> >>>
> >>> Quickshot ...
> >>>
> >>> <antcontrib:for param="todir">
> >>>     <!-- specify the target directories -->
> >>>     <dirset/>
> >>>     <sequential>
> >>>         <copy todir="@{todir}">
> >>>             <!-- specify the files to copy -->
> >>>             <fileset/>
> >>>         </copy>
> >>>     </sequential>
> >>> </antcontrib:for>
> >>>
> >>>
> >>> AFAIK there is no build-in way, so you have to iterate for your own.
> >>>
> >>>
> >>> Jan
> >>>
> >>>
> >>>
> >>>>-----Ursprüngliche Nachricht-----
> >>>>Von: Camer38 [mailto:rembiszm@gmail.com]
> >>>>Gesendet: Dienstag, 13. Februar 2007 17:30
> >>>>An: user@ant.apache.org
> >>>>Betreff: Copy a single file to directories
> >>>>
> >>>>
> >>>>Hi,
> >>>>
> >>>>I would like to copy a single file to multiply directories.
> >>>>Every time the structure of folders may vary.
> >>>>One file has to be copy into every catalog under ./test/components
> >>>>
> >>>>Any idea?
> >>>>
> >>>>Thanks in advance
> >>>>Marcin
> >>>>--
> >>>>View this message in context:
> >>>>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
> >>>>51.html#a8947606
> >>>>Sent from the Ant - Users mailing list archive at Nabble.com.
> >>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >>>>For additional commands, e-mail: user-help@ant.apache.org
> >>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >>> For additional commands, e-mail: user-help@ant.apache.org
> >>>
> >>>
> >>>
> >>
> >>--
> >>View this message in context:
> >>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
> >>51.html#a8948408
> >>Sent from the Ant - Users mailing list archive at Nabble.com.
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >>For additional commands, e-mail: user-help@ant.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8948784
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

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


Re: AW: AW: Copy a single file to directories

Posted by Camer38 <re...@gmail.com>.
Ok, let me take a deep look...


Jan.Materne wrote:
> 
>>Thanks for a quick answer.
>>Could you be more elaborative and deliver more complex example, please.
>>At this moment I have a very brief idea how to use antcontrib
> 
> 
> Not without more information. Have you played with that code?
> 
> 
> Jan
> 
> 
>>
>>Thanks in advance - I relay appreciate you help.
>>
>>Marcin
>>
>>
>>Jan.Materne wrote:
>>> 
>>> Quickshot ...
>>> 
>>> <antcontrib:for param="todir">
>>>     <!-- specify the target directories -->
>>>     <dirset/>
>>>     <sequential>
>>>         <copy todir="@{todir}">
>>>             <!-- specify the files to copy -->
>>>             <fileset/> 
>>>         </copy>
>>>     </sequential>
>>> </antcontrib:for>
>>> 
>>> 
>>> AFAIK there is no build-in way, so you have to iterate for your own.
>>> 
>>> 
>>> Jan
>>> 
>>> 
>>> 
>>>>-----Ursprüngliche Nachricht-----
>>>>Von: Camer38 [mailto:rembiszm@gmail.com] 
>>>>Gesendet: Dienstag, 13. Februar 2007 17:30
>>>>An: user@ant.apache.org
>>>>Betreff: Copy a single file to directories
>>>>
>>>>
>>>>Hi,
>>>>
>>>>I would like to copy a single file to multiply directories.
>>>>Every time the structure of folders may vary.
>>>>One file has to be copy into every catalog under ./test/components
>>>>
>>>>Any idea?
>>>>
>>>>Thanks in advance
>>>>Marcin
>>>>-- 
>>>>View this message in context: 
>>>>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
>>>>51.html#a8947606
>>>>Sent from the Ant - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>>For additional commands, e-mail: user-help@ant.apache.org
>>>>
>>>>
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>> 
>>> 
>>> 
>>
>>-- 
>>View this message in context: 
>>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
>>51.html#a8948408
>>Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8948784
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: AW: Copy a single file to directories

Posted by Camer38 <re...@gmail.com>.
Thanks for a quick answer.
Could you be more elaborative and deliver more complex example, please.
At this moment I have a very brief idea how to use antcontrib

Thanks in advance - I relay appreciate you help.

Marcin


Jan.Materne wrote:
> 
> Quickshot ...
> 
> <antcontrib:for param="todir">
>     <!-- specify the target directories -->
>     <dirset/>
>     <sequential>
>         <copy todir="@{todir}">
>             <!-- specify the files to copy -->
>             <fileset/> 
>         </copy>
>     </sequential>
> </antcontrib:for>
> 
> 
> AFAIK there is no build-in way, so you have to iterate for your own.
> 
> 
> Jan
> 
> 
> 
>>-----Ursprüngliche Nachricht-----
>>Von: Camer38 [mailto:rembiszm@gmail.com] 
>>Gesendet: Dienstag, 13. Februar 2007 17:30
>>An: user@ant.apache.org
>>Betreff: Copy a single file to directories
>>
>>
>>Hi,
>>
>>I would like to copy a single file to multiply directories.
>>Every time the structure of folders may vary.
>>One file has to be copy into every catalog under ./test/components
>>
>>Any idea?
>>
>>Thanks in advance
>>Marcin
>>-- 
>>View this message in context: 
>>http://www.nabble.com/Copy-a-single-file-to-directories-tf32216
>>51.html#a8947606
>>Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Copy-a-single-file-to-directories-tf3221651.html#a8948408
Sent from the Ant - Users mailing list archive at Nabble.com.


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