0
votes

I am new to Powershell and Robocopy usage.

I am trying to send some files to destination path. But destination path contains some files that is not contained in source. I want that files remain intact after copy operation.

When i try to run Robocopy from a powershell script like this:

Robocopy sourcePath destinationPath /MIR

it syncs two paths. So that destinationPath lonely files are deleted. Is there any way to prevent this behavior?

1

1 Answers

2
votes

Don't use the /MIR flag. That is exactly to keep the source and destination in sync, including deletion of files missing in source.

Use robocopy /E to copy a folder structure including empty subfolders. By default it only copies new and newer files.