Hi D4zza — yes, Robocopy can do exactly that. Use the /MIR (mirror) or the /PURGE switch to make the destination match the source (including deleting files in E that were deleted from D). A few important cautions and a safe example follow.
Short summary
- /MIR = mirror trees (same as /E plus /PURGE) — it will remove files/dirs in destination that don't exist in source.
- /PURGE deletes files/dirs in destination that are not in source (use with /E if you want empty dirs preserved).
- Always test first with /L (list-only) so you can see what would be changed without actually changing anything.
Quick preview (no changes)
robocopy "D:\" "E:\" /MIR /L /NJH /NJS /NDL /NP
Real run (example)
robocopy "D:\" "E:\" /MIR /Z /R:2 /W:5 /MT:8 /V /NP /LOG:"%USERPROFILE%\robocopy_mirror.log"
What those switches do (most useful ones)
- /MIR — mirror source to destination (will delete extra files on destination).
- /PURGE — delete destination files and directories that no longer exist in source (alternative to /MIR when you want control).
- /E — copy subdirectories, including empty ones (if you use /PURGE you typically add /E).
- /Z — restartable mode (good for USB disconnects).
- /R:n and /W:n — retry count and wait seconds (avoid long hangs on bad files).
- /MT:n — multi-threaded copy (faster; default n=8, up to 128).
- /L — list-only (very useful to preview what will happen).
- /LOG:filename and /TEE — record output to a log and print to console.
- /NP — no progress (reduces console spam).
- /V — verbose.
Safety tips (very important)
- Run with /L first — always check what Robocopy would delete before you run it for real.
- Be careful with drive letters: if D: or E: change (you plug other drives in) the script could wipe the wrong disk. Add a check for volume label or prompt for confirmation before running.
- Keep a recent backup (or test on a small folder first). /MIR will permanently delete files on the destination if they no longer exist on the source.
- If you want file ACLs and attributes copied, use /COPYALL or /SEC as needed.
Safe batch example that asks for confirmation by volume label
Save this as MirrorDtoE.bat and edit labels to match your drives.
@echo off
set "SRC=D:"
set "DST=E:"
for /f "tokens=2 delims==" %%a in ('wmic logicaldisk where "DeviceID='%SRC%'" get VolumeName /value ^| find "="') do set "SRC_LABEL=%%a"
for /f "tokens=2 delims==" %%a in ('wmic logicaldisk where "DeviceID='%DST%'" get VolumeName /value ^| find "="') do set "DST_LABEL=%%a"
echo Source: %SRC% Label: "%SRC_LABEL%"
echo Dest: %DST% Label: "%DST_LABEL%"
set /p "CONF=Proceed with mirror from %SRC% to %DST% (type Y to continue)? "
if /i not "%CONF%"=="Y" goto :eof
robocopy "%SRC%\" "%DST%\" /MIR /Z /R:2 /W:5 /MT:8 /V /NP /LOG:"%~dp0robocopy_mirror.log" /TEE
pause
Other options (GUI/free)
- FreeFileSync — free GUI tool with a “Mirror” mode that deletes destination entries to match the source. It’s easier to preview and has a realtime option (and you still get a normal filesystem on the destination).
- SyncToy (legacy) /rsync ports for Windows — also options, but Robocopy + /MIR is native and reliable.
If you want, I can:
- Give a one-line test you can paste into a command prompt to preview the exact deletes, or
- Produce a finished safe .bat that checks labels and logs output for you (tell me your source and destination drive letters and their volume labels if you want the label-check script).
Which would you prefer?