I have a cross-platform build toolchain which copies some folders to destination. I use robocopy on Windows and rsync on macOS because they support console progress output. The commands were in this form:

robocopy "C:\Some\Source" "C:\Some\Destination" /MIR
rsync -a --progress --delete "/Some/Source/" "/Some/Destination"

But now I am met with a situation where I need to exclude some files that may appear in the source directory. And I need them to be erased in the destination if they were there before. rsync has --delete-excluded option:

rsync -a --progress --delete-excluded --exclude '*.jpg' "/Some/Source/" "/Some/Destination"

But I can't make robocopy act like this using the /XF option:

robocopy "C:\Some\Source" "C:\Some\Destination" /MIR /XF *.jpg

robocopy keeps old excluded files at the destination. Is there a way to make robocopy behave like rsync with the --delete-excluded option? I know I can scan the destination tree later to remove excluded files with another command but I would like to do it with robocopy because the tree is really huge and I want to save time with the copy operation.

  • Did you find a solution? I am having a similar problem.
    – olfek
    Feb 9, 2020 at 12:32
  • 3
    @daka sorry, but I had no luck with that :( Instead I cleaned everything manually and reorganized my build pipeline so such files are not appearing anymore.
    – dmitry1100
    Feb 14, 2020 at 6:32


You must log in to answer this question.

Browse other questions tagged .