This page has tells how to remove files in Directory B that also exist in Directory A.
I want to use the windows solution but without the copying.
Can someone tell me how to edit the FOR line to just do the compare and then delete? Thank you.
This page has tells how to remove files in Directory B that also exist in Directory A.
I want to use the windows solution but without the copying.
Can someone tell me how to edit the FOR line to just do the compare and then delete? Thank you.
cd /d "c:\dir_B" && for %i in (*)do if exist "C:\Dir_A\%~nxi" echo\Del "%~i" /q /f
1. Go to Dir_B folder: pushd "D:\Dir_B"
2. Use one simple for loop to list yours files: for %i in (*)do...
3. Test if exist your file in Dir_A folder: if exist "D:\Dir_A\%~nxi"
4. If last command return true, delete this file in current Dir_B: del "%~fi"
@(pushd "D:\Dir_B" && (for %i in (*)do if exist "D:\Dir_A\%~nxi" del "%~fi")) & popd
@(pushd "D:\Dir_B" && (for %%i in (*)do if exist "D:\Dir_A\%%~nxi" del "%%~fi")) & popd
dir
and operator &&
@(pushd "D:\Dir_B" && (for %i in (*)do 2>nul 2>&1 dir /b "D:\Dir_A\%~nxi" && del "%~fi")) & popd
@echo off
set "_SourceDir=C:\Users\Steve\Desktop\Barnes 330 Discovery Recd 2018-20-15\KV Emails\Source"
set "_DestDir=C:\Users\Steve\Desktop\Barnes 330 Discovery Recd 2018-20-15\KV Emails\SourceDupes"
cd /d "%_SourceDir%" && for %%a in (*.*)do if exist "%_DestDir%\"%%~nxa" 2>nul del /q /f "%%~dpnxa"
Some further reading:
[√] Pushd
[√] Popd
[√] For Loop
[√] For /F Loop
[√] For /R Loop