PowerShell - suppress Copy-Item 'Folder already exists' error

You can set the error handling behavior to ignore using:

Copy-Item "C:\realFolder\*" "C:\realFolder_new" -recurse -ErrorAction SilentlyContinue

However this will also suppress errors you did want to know about!


If you add -Force to your command it will overwrite the existing files and you won't see the error.

-Recurse will replace all items within each folder and all subfolders.

Copy-Item "C:\realFolder\*" "C:\realFolder_new" -Recurse -Force

You could try capturing any errors that happen, and then decide whether you care about it or not:

Copy-Item "C:\realFolder\*" "C:\realFolder_new" -recurse -ErrorVariable capturedErrors -ErrorAction SilentlyContinue
$capturedErrors | foreach-object { if ($_ -notmatch "already exists") { write-error $_ } }