How to overwrite existing files in batch?

后端 未结 10 1324
猫巷女王i
猫巷女王i 2021-01-30 15:17

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
10条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 15:59

    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.

提交回复
热议问题