I am trying to create a batch file that will Copy files from say d:\temp to c:\temp and if the file already exists on c:\temp to actually delete it from c:\temp, do not attempt to copy that file and continue copying remaining files. Repeat if exists etc.
Asked
Active
Viewed 6,843 times
1 Answers
2
Here you go
for /r D:\temp %%a in (*) do (
if exist "C:\temp\%%~nxa" (
del "C:\temp\%%~nxa" /f /s /q
) else (
copy "%%a" C:\temp
)
)

Bali C
- 30,582
- 35
- 123
- 152