0

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.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
user1724636
  • 3
  • 1
  • 3

1 Answers1

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