Windows 10: Xcopy syntax for multiple source directories Solved

  1. tcebob's Avatar
    Posts : 387
    Windows 10 pro 1803/17134.285
       06 Jul 2017 #1

    Xcopy syntax for multiple source directories


    can someone show me a sample xcopy command to copy C:\Directory1 and C:\Directory2 to a destination directory H:\DestinationDirectory?
      My ComputerSystem Spec

  2.    07 Jul 2017 #2

    try the loop,

    Code:
    for %%a in (
     "C:\Directory1"
     "C:\Directory2"
      ) do (
    xcopy /s /d "%%~a" "H:\DestinationDirectory"
      )
      My ComputerSystem Spec

  3. tcebob's Avatar
    Posts : 387
    Windows 10 pro 1803/17134.285
    Thread Starter
       07 Jul 2017 #3

    Very good, I will use it.

    In cmd, xcopy help states "source Specifies the file(s) to copy." but does not detail how to list them.

    is the squiggle in %%~a intentional or a typo?
      My ComputerSystem Spec

  4.    07 Jul 2017 #4

    the above syntax is to be used in a batch file.

    here's a single liner for cmd:

    Code:
    for %a in ("C:\Directory1" "C:\Directory2") do (xcopy /s /d "%~a" "H:\DestinationDirectory")

    yes, the squiggle is intentional, it's for a short and long pathnames element.
      My ComputerSystem Spec

  5. tcebob's Avatar
    Posts : 387
    Windows 10 pro 1803/17134.285
    Thread Starter
       07 Jul 2017 #5

    Ah, so. Odd, the d/ switch is not listed in cmd help. I changed s/ to e/ because, as a backup, I want a complete image, including empty directories.
      My ComputerSystem Spec

  6. tcebob's Avatar
    Posts : 387
    Windows 10 pro 1803/17134.285
    Thread Starter
       07 Jul 2017 #6

    Tried and failed. My bad, probably. I cannot find how to include the actual code as you did, and copying directly to this editor removes line feeds.
      My ComputerSystem Spec

  7.    10 Jul 2017 #7

    tcebob said: View Post
    Ah, so. Odd, the d/ switch is not listed in cmd help. I changed s/ to e/ because, as a backup, I want a complete image, including empty directories.
    the /d switch is for date. if not specify, only the newer files will be copied.

    tcebob said: View Post
    Tried and failed. My bad, probably. I cannot find how to include the actual code as you did, and copying directly to this editor removes line feeds.
    You can try the single line syntax above, just double the percent sign (%a to %%a) if you wish to create a batch file.
      My ComputerSystem Spec

  8. tcebob's Avatar
    Posts : 387
    Windows 10 pro 1803/17134.285
    Thread Starter
       10 Jul 2017 #8

    Thanks for your patient help.
    I will mark this as solved

    This is a test of the Code tags:

    Code:
    Explorer /root, \\server\share, select, Program.exe
    Aha! it worked.
      My ComputerSystem Spec


 

Related Threads
In Audit mode, if I run the %SystemRoot%\System32\Cmd.exe /c cleanmgr /sageset:65535 & cleanmgr /sagerun:65535 command from the Command Prompt, the "Disk Cleanup Settings" window is displayed. So, I select all the items and press Ok. Now, before...
I have all these directories starting with Qui...tmp on one of my laptops. about 20-30 of them, all empty. I get nothing via google. Anyone ever seen this?
VIM Syntax Highlighting in Windows Insider
I've been playing around with the new Bash just fine - all is well! When I set up my .vimrc, everything also worked well. I installed all my usual plugins, and my keymappings work fine. The only problem is with the colorscheme and syntax...
Windows 10 and DVD directories in General Support
I have an issue I can't seem to find decent info about. My Win 10 laptop won't see files and folders on DVDs I burned on another box unless I make an ISO on the Win 7 machine first, and then copy it over to the Win 10 machine and "mount" the ISO. ...
Merge Directories in General Support
I have two large Directories (about 25 GB each, 6-7000 files) that contain similar information. One may have newer files than the other. I would like to merge them into one Directory and eliminate duplicate files. Is there some software that...
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 22:44.
Find Us