The following command copies and moves a file but I also need it to overwrite the file it\'s replacing.
xcopy /s c:\\mmyinbox\\test.doc C:\\myoutbox
Add /Y to the command line
Here's what worked for me to copy and overwrite a file from B:\ to Z:\ drive in a batch script.
echo F| XCOPY B:\utils\MyFile.txt Z:\Backup\CopyFile.txt /Y
The "/Y" parameter at the end overwrites the destination file, if it exists.
If destination file is read only use /y/r
xcopy /y/r source.txt dest.txt
A command that would copy in any case
xcopy "path\source" "path\destination" /s/h/e/k/f/c/y
you need to simply add /Y
xcopy /s c:\mmyinbox\test.doc C:\myoutbox /Y
and if you're using path with spaces, try this
xcopy /s "c:\mmyinbox\test.doc" "C:\myoutbox" /Y
Add /y
to the command line of xcopy
:
Example:
xcopy /y c:\mmyinbox\test.doc C:\myoutbox