1.    06 Jul 2017 #1
    Join Date : Sep 2015
    Posts : 291
    Windows 10

    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
    Join Date : Jan 2016
    Posts : 151
    Windows 10

    try the loop,

    Code:
    for %%a in (
     "C:\Directory1"
     "C:\Directory2"
      ) do (
    xcopy /s /d "%%~a" "H:\DestinationDirectory"
      )
      My ComputerSystem Spec
  3.    07 Jul 2017 #3
    Join Date : Sep 2015
    Posts : 291
    Windows 10
    Thread Starter

    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
    Join Date : Jan 2016
    Posts : 151
    Windows 10

    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.    07 Jul 2017 #5
    Join Date : Sep 2015
    Posts : 291
    Windows 10
    Thread Starter

    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.    07 Jul 2017 #6
    Join Date : Sep 2015
    Posts : 291
    Windows 10
    Thread Starter

    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
    Join Date : Jan 2016
    Posts : 151
    Windows 10

    Quote Originally Posted by tcebob 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.

    Quote Originally Posted by tcebob 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.    10 Jul 2017 #8
    Join Date : Sep 2015
    Posts : 291
    Windows 10
    Thread Starter

    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

 


Similar Threads
Thread Forum
"The syntax of the file name, directory or volume is not correct."
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...
Performance & Maintenance
Quixxxx.tmp directories on root
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?
General Support
VIM Syntax Highlighting
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 Insider
Windows 10 and DVD directories
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. ...
General Support
Merge Directories
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...
General Support
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 15:04.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums