windowsbatch-filecmdxcopy

XCOPY: Overwrite all without prompt in BATCH


I'm writing a batch program for copying all files newer than the destination from "C:\Users\ADMIN\Desktop" to "D:\Backup".

This code is works:

xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H

However, it asks for each existing destination file: Overwrite file [Yes / No / All]?

I want to overwrite all existing destination files without user intervention.

How can I solve this?


Solution

  • The solution is the /Y switch:

    xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H /Y