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

Sarah Vessels picture Sarah Vessels · Jun 10, 2010 · Viewed 371.9k times · Source

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.

Answer

Shea picture Shea · Jun 10, 2010

I use

echo f | xcopy /f /y srcfile destfile

to get around it.