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
.
This is from Bills answer.
Just to be really clear for others.
If you are copying ONE file from one place to another AND you want the full directory structure to be created, use the following command:
Yes, put a backslash at the end of the file name and it will NOT ask you if it's a file or directory. Because there is only ONE file in the source, it will assume it's a file.
xcopy src dest /I
REM This assumes dest is a folder and will create it, if it doesnt exists
You cannot specify that it's always a file. If you don't need xcopy's other features, why not just use regular
copy
?There is some sort of undocumented feature in XCOPY. you can use:
xcopy "bin\development\whee.config.example" "c:\mybackup\TestConnectionExternal\bin\Debug\whee.config*"
i tested it just today. :-)
Back to the original question:
could be done with two commands eg:
By simply appending "\.." to the path of the destination file the destination directory is created if it not already exists. In this case
which is the parent directory of the non-existing directory
At least for WIN7 mkdir does not care if the directory
really exists.
I use
to get around it.