How to copy 1st level directories C:\ as source using xxcopy

Page 2 of 2 FirstFirst 12

  1. Posts : 4,173
    Windows 11 Pro, 22H2
       #11

    Run 2 robocopy commands. The first to copy just the level 2 folders without subdirectories or contents, and then one more to copy just the one folder out of the 74 that you want to copy.

    If you place them in a batch file then you only need to run the one command (the batch file) manually.
      My Computers


  2. Posts : 37
    Windows 10 Enterprise
    Thread Starter
       #12

    hsehestedt said:
    Run 2 robocopy commands. The first to copy just the level 2 folders without subdirectories or contents, and then one more to copy just the one folder out of the 74 that you want to copy.
    but if i do level 2 copy... that is the subdirectories level inside C:\Downloads
      My Computer


  3. Posts : 4,173
    Windows 11 Pro, 22H2
       #13

    I'm still not 100% sure on what the exact goal is, so the exact command I provided may not be quite right in your circumstance.

    The way it is worded confuses me.

    I want to know how to copy 1st level directories within the C:\ drive to another external hard drive. More Specifically, I just want to copy the "C:\Downloads" folder into "E:". I do not want any subdirectories or files to be copied, just folders.
    So assuming you have the following as an example:

    Code:
    C:\
       Downloads
          File1
          FolderA
       Folder1
          File2
       Folder2
          File3
          FolderC
       File4
    So what in this structure what do you want to copy and to where? You say that you want to copy just C:\Downloads to E:. You do not want to copy subdirectories or files. Does this mean that you do not want to copy subdirectories or folders OTHER than those in C:\Downloads or do you also not want to copy files and subdirectories with C:\Downloads? Also, to where on E: do you want to copy? To E:\?

    Feel free to include an directory listing with explanation if that is easier.

    I hope that you understand - in order to give a precise command(s), I need precise data to work with.
      My Computers


  4. Posts : 37
    Windows 10 Enterprise
    Thread Starter
       #14

    more specifically, my question is I want to copy C:\Downloads folder into E:\ so that the folder structure will be: E:\Downloads. I just want to copy 1st level folders inside C:\Downloads; no files within C:\Downloads folder or 2nd level folders ex. C:\Downloads\subdirectory1...2...3..etc..

    What really bugs me is that robocopy has a command to exclude 1 folder. But it doesn't have exclude ALL folders except a given set of folders.. in other words EXCLUDE ALL but a few folders or alternatively, include only a select set of folders

    How to copy 1st level directories C:\ as source using xxcopy-image.png
      My Computer


  5. Posts : 4,173
    Windows 11 Pro, 22H2
       #15

    Ah, yes. I understand.

    The closest thing that I could think of to being able to exclude all folders except a select list of folders, is to do something like the following:

    Output a directory listing of folders to a text file.

    For example:

    Code:
    C:\>dir /A:D /B > D:\MyFolderList.txt
    When I look in the file I see this:

    Code:
    $Recycle.Bin
    $WINDOWS.~BT
    $Windows.~WS
    Documents and Settings
    ESD
    Intel
    MountPoints
    New folder
    PerfLogs
    Program Files
    Program Files (x86)
    ProgramData
    Recovery
    swsetup
    System Volume Information
    usbcreate
    Users
    Windows
    Code:
    /A:D
    tells dir to only list directories. The /B puts out the list in a bare format.

    So now you have a list of folders that you exclude by pasting them into a job file. Simply delete the folder names that you still want to copy.

    Create a job file that includes a list of the folders to be excluded like this:


    Code:
    ::
    :: Exclude These Directories :
    ::
    	/XD		:: eXclude Directories matching these names
    $Recycle.Bin
    $WINDOWS.~BT
    $Windows.~WS
    Program Files
    Program Files (x86)
    ProgramData
    Recovery
    System Volume Information
    TIP: To create a job file do this:

    Create a test file to hold the job. For example, let's say I create a file called E:RoboJob.rcj. Make sure to include the .rcj extension.

    Now, run a robocopy job that might be similar to what you want to do. or example:

    Code:
    robocopy c:\Source D:\Destination /mir /xd ExcludedFolder /save:E:\RoboJob /L
    Note that I have a /L so no action will be taken, but a job file will be created. Note also that I omitted the extension because robocopy will add the .rcj extension.

    Now, modify the job file to add a list of folders to excluse as shown in the lines I noted above.

    To run the command with the job rather than a /save use a /job:RoboJob command like this:

    Code:
    robocopy /job:Robojob /L
    (or omit the /L to actually execute the job).

    So yes, robocopy is not perfect. There are times need to get creative and multiple commands, or you can execute more complex logic by calling it from a batch file using things like a for loop or other logic.

    I hope that this helps!
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:27.
Find Us




Windows 10 Forums