Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 965
Sarah Vessels Avatar asked Jun 10 '10 20:06

Sarah Vessels


People also ask

Does specify a filename or directory xcopy?

By default, xcopy prompts you to specify whether Destination is a file or a directory. Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory. Copies all subdirectories, even if they are empty.

Which is better copy or xcopy?

In most cases copying a single file is best done with the COPY command. When copying a single file with XCOPY, there is no option to indicate if the destination is a filename or a directory (with the filename defaulting to that of the source file).

Should I use xcopy or Robocopy?

Unlike Xcopy, Robocopy is used to mirror or synchronize directories. Robocopy will be able to check the target directory and delete files that are no longer in the main tree, instead of copying all files from one directory to another.

How do I exclude files from xcopy?

Using /excludeIf any of the listed strings match any part of the absolute path of the file to be copied, that file is then excluded from the copying process. For example, if you specify the string "\Obj", you exclude all files underneath the Obj directory.


2 Answers

I use

echo f | xcopy /f /y srcfile destfile 

to get around it.

like image 170
Shea Avatar answered Oct 08 '22 12:10

Shea


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.

like image 20
LBushkin Avatar answered Oct 08 '22 12:10

LBushkin