Robocopy /XD Won't Work With Relative Paths

I am trying to run a robocopy /MOVE command but exclude a couple of sub-directories specified with the /XD flag.

robocopy ".\CurrentDir" ".\NewDir" /XD ".\CurrentDir\SubDir1" ".\CurrentDir\SubDir2" /E /MOVE

Unfortunately it ignores the /XD option and moves everything. If I use an absolute path on everything, it works fine, but I need this to be flexible. Is there any way to make it work with relative paths?


Solution 1:

The folders specified for /XD are referring to folders (to exclude) that exist within the source folder, so you only specify the folder name(s) you wish to exclude, without specifying a parent relation.

ie:

robocopy ".\CurrentDir" ".\NewDir" /XD "SubDir1" "SubDir2" /E /MOVE