Can ROBOCOPY copy only specified folders and contents and skip folders not required for copy

Peter Mulholland 0 Reputation points
2024-01-09T09:37:42.35+00:00

A parent folders contains hundreds of sub folders. Can ROBOCOPY copy only specified sub folders and contents and skip sub folders not required for copy?

What would be the arguement for that?

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
12,051 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,704 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Thierry DEMAN-BARCELO 491 Reputation points MVP
    2024-01-09T09:53:26.94+00:00

    Hello,

    you can use the option XD to exclude a list of folders

    /XD folder1 Folder2

    And XF to exclude some files

    /XF file1 File2

    0 comments No comments

  2. Ian Xue 39,371 Reputation points Microsoft Vendor
    2024-01-10T04:24:06.7933333+00:00

    Hi Peter Mulholland,

    There is only option to exclude sub folders and no option to specify sub folders to copy. You can try some PowerShell script like this. Replace $dirs with your sub folder names.

    $source = "C:\source"
    $destination = "C:\destination"
    $dirs = ("dir1","dir2","dir3")
    $dirs | ForEach-Object { Robocopy "$source\$_" "$destination\$_" }
    

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.