How to say no to all “do you want to overwrite” prompts in a batch file copy?

后端 未结 14 1314
感动是毒
感动是毒 2020-12-23 11:36

By default, copying from the command prompt will prompt you to overwrite files that already exist in the target location.

You can add \"/Y\" to say \"Yes to all\" re

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 11:42

    Try this:

    robocopy "source" "destination" /e /b /copyall /xo /it
    

    Copy that line into notepad and save as a .bat file. Run the file and it will copy everything from the source to the destination. When you run it again it will not replace files that are identical. when you change or a file changes it will replace the file at the destination.

    test it out. I created a .txt file with a few works, ran the script, change the wording on the .txt file and ran the script again, it replace only the change file from the source.

    /e=Copies subdirectories. Note that this option includes empty directories
    /b=Copies files in Backup mode
    /copyall=Copies all file information
    /xo=Excludes older files. (this is what prevents it from copy the same file over and over)
    /it=Includes "tweaked" files. (this will allow the copy and replace of modified files)
    

提交回复
热议问题