XCOPY: Overwrite all without prompt in BATCH

209,571

The solution is the /Y switch:

xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H /Y
Share:
209,571
FZs
Author by

FZs

What can I write here? :)

Updated on August 13, 2021

Comments

  • FZs
    FZs over 2 years

    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?

  • ttfreeman
    ttfreeman about 4 years
    the /Y option only overwrites the pre-existing files: lifewire.com/xcopy-command-2618103
  • ttfreeman
    ttfreeman about 4 years
    In my case, I am looking to overwrite EVERYTHING. the contents of one folder to replace another folder's content
  • ttfreeman
    ttfreeman about 4 years
    I know, stupid windows. each one of them has a different problem. rmdir says folder is in use by another applicaion, Poweshell Remove-Item says dies not have permission and so on.