views:

456

answers:

4

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.

+1  A: 

You cannot specify that it's always a file. If you don't need xcopy's other features, why not just use regular copy?

Gabe
+3  A: 

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.

LBushkin
+4  A: 

I use

echo f | xcopy /f /y srcfile destfile

to get around it.

Arnshea
A: 

Use copy instead of xcopy when copying files.

e.g. copy "bin\development\whee.config.example" "TestConnectionExternal\bin\Debug\whee.config"

Peter