How to overwrite existing files in batch?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 16:02:07

Add /Y to the command line

Benoit

You can use :

copy /b/v/y

See SS64 on COPY.

christopher.wr.schill

Add /y to the command line of xcopy:

Example:

xcopy /y c:\mmyinbox\test.doc C:\myoutbox

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

If the copy command is run from within a batch job you do not need to use the /Y switch: it will overwrite existing files.

You can refer Windows command prompt help using following command : xcopy /?

If destination file is read only use /y/r

xcopy /y/r source.txt dest.txt
Raj Sharma

A command that would copy in any case

xcopy "path\source" "path\destination" /s/h/e/k/f/c/y
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!