Windows 7 Copy certain files using command prompt recreating folder structure

Discussion in 'Programming and Scripting' started by -null-, Aug 13, 2012.

  1. -null-

    -null- Honorable Member

    Joined:
    Feb 5, 2009
    Messages:
    34
    Likes Received:
    2
    At the moment I am using an xcopy command to copy all files with a certain extension to another folder. As the number of files in this folder increases I'd like to organise them into sub folders and have the directory structure mirrored. However I don't want the entire folder contents copied over as there are files not needed in the destination.

    My command is currently this
    Code:
    XCOPY "$(ProjectDir)usercontrols\*.ascx" "..\..\..\Website\usercontrols\" /Y
    If I organise my ascx files into sub directories, can xcopy recreate the structure but only copying the .ascx files needed in the destination. Or is there another command line utility that can do so.
     
  2. -null-

    -null- Honorable Member

    Joined:
    Feb 5, 2009
    Messages:
    34
    Likes Received:
    2
    Did a big more googling and found out about the robocopy utility. The following using that seems to work

    Code:
    ROBOCOPY "$(ProjectDir)usercontrols" "..\..\..\Website\usercontrols" *.ascx /copy:TD /s /xx /njh /np
     
  3. AceInfinity

    AceInfinity Senior Member
    Microsoft MVP

    Joined:
    Aug 12, 2011
    Messages:
    159
    Likes Received:
    11
    I was going to suggest robocopy as well before I seen that it was also suggested here. I like the fact that it's also a threading capable utility for multiple operations running asynchronously, but in general it's configurability is a +1 from me. I use it to backup my development projects folder.
     

Share This Page

Loading...