Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Copy Task Recursion Question

Back to Forum: Tech Off
  • User profile image
    rcooke

    I have an usual copy task I need to accomplish.  I want all files in each child folder of the source location to be copied to the corresponding PARENT folder in the destination location but I havent been able to come up with a way to have the recursive copy command do this.  Is this possible with the generic copy task or do I need to write a custom task in C# to do this?

    This is my source folder structure:
     
     SourceFolder
      ParentFolder1
       ChildFolder
        -File1.cs
        -File2.cs
      ParentFolder2
       ChildFolder
        -File1.cs
        -File2.cs

    This is what I want in the destination folder:

     DestinationFolder
      ParentFolder1
       -File1.cs
       -File2.cs
      ParentFolder2
       -File1.cs
       -File2.cs
      
    This is what my current RetrieveFiles target creates: 

     DestinationFolder
      ParentFolder1
       ChildFolder
        -File1.cs
        -File2.cs
      ParentFolder2
       ChildFolder
        -File1.cs
        -File2.cs
     
    <Target Name="RetrieveFiles">

     <CreateItem Include="$(SourceFolder)\**\ChildFolder\*.*">
      <Output TaskParameter="Include" ItemName="SourceFiles"/>
     </CreateItem>

     <Copy
      SourceFiles="@(SourceFiles)"
      DestinationFiles="@(SourceFiles->'$(DestinationFolder)\%(RecursiveDir)%(Filename)%(Extension)')"
     />
    </Target>


    Thanks, BC

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.