Tiny Windows batch utility that overwrites only the files that already exist in the destination folder — without copying new files.
Useful for “patching” an existing folder with updated versions from another folder.
OverwriteExisting is a lightweight Windows .bat script built on top of robocopy:
- Overwrite only existing files in DEST (B) using files from SRC (A)
- No new files are added to DEST (source-only files are excluded)
- Prints detailed copy output to the console and writes a log file next to the script
- Works well with paths containing spaces and Korean characters
The script runs robocopy with options that effectively mean:
- Copy from
SRC→DEST - Exclude “source-only” items so DEST does not get new files (
/XL) - Force overwrite behavior for same/tweaked files (
/IS /IT) - Log to console + file (
/TEE /UNILOG)
- Put
overwrite_existing.batanywhere you like. - Run it and input paths:
overwrite_existing.bat- DEST (B):
D:\destination - SRC (A):
D:\source
The script will overwrite only the files that already exist in D:\destination.
==================================================
overwrite_existing (robocopy)
Log: D:\overwrite_existing_20260126_152409.log.txt
==================================================
DEST: [D:\destination]
SRC : [D:\source]
---- Running robocopy (overwrite ONLY existing files in DEST) ----
...
ROBOCOPY exit code: 1
Status: OK
Log saved to: D:\overwrite_existing_20260126_152409.log.txt
Robocopy exit code note
robocopyuses bitmask exit codes. Typically 0–7 are OK, and 8+ indicates failures.
If you want to preview what would be copied, add /L to the robocopy line:
robocopy "%SRC%" "%DEST%" *.* /XL /IS /IT /L ...If you want to include subfolders, add /E to the robocopy line:
robocopy "%SRC%" "%DEST%" *.* /E /XL /IS /IT ...- Windows with
robocopyavailable (Windows Vista and later, including Windows 10/11)
This project is licensed under the MIT License.
See the LICENSE file for details.