Search code examples
cmdxcopy

Xcopy error: invalid number of parameters


I am trying to copy files from E:/bin/Debug/ to E:/New using xcopy. My syntax is

xcopy /s "E:\bin\Debug*.*E:\New"

on windows 10.

It returns

error invalid number of parameter

or sometimes

New not foundinvalid path

. Please help me to find my mistake. What am I doing wrong?


Solution

  • You need a space between the arguments, and each parameter needs to be in quotes*.

    E:\> xcopy /s /i "E:\bin\Debug\*.*" "E:\New\"
    E:\bin\Debug\Test\InnerDir\FileA.txt
    E:\bin\Debug\Test\InnerDir\FileB.txt
    2 files copied
    

    By default xcopy does not create the target directory if it does not exist. Use the /i option if that is what you want. xcopy documentation can be found here.

    /i:
    If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory.

    Alternatively you can use mkdir to create 'E:\New\'

    Quotemarks*: Only needed when your arguments contain spaces, such as Directory names like Program Files, which have spaces. But it's a good idea to always include them.