Search code examples
command-linecommand-promptxcopy

xcopy file, rename, suppress "Does xxx specify a file name..." message


This seems pretty simple and maybe I'm just overlooking the proper flag, but how would I, in one command, copy a file from one directory to another and rename it in the destination directory? Here's my command:

if exist "bin\development\whee.config.example"
  if not exist "TestConnectionExternal\bin\Debug\whee.config"
    xcopy "bin\development\whee.config.example"
          "TestConnectionExternal\bin\Debug\whee.config"

It prompts me with the following every time:

Does TestConnectionExternal\bin\Debug\whee.config specify a file name or directory name on the target (F = file, D = directory)?

I want to suppress this prompt; the answer is always F.


Solution

  • Don't use the xcopy, use copy instead, it doesn't have this issue.

    xcopy is generally used when performing recursive copies of multiple files/folders, or when you need the verification/prompting features it offers. For single file copies, the copy command works just fine.