I'd like to exclude all files matching C:\dir1\*.ext
so I say:
robocopy C:\dir1 C:\dir2 /E /B /MIR /xf C:\dir1\*.ext
According to the documentation this should work:
/xf <FileName>[ ...]
Excludes files that match the specified names or paths. Note that FileName can include wildcard characters (* and ?).
But it results in:
ERROR : Invalid Parameter #16 : "xyz"
How can I exclude based on this pattern? Excluding by directory or by file name pattern is not specific enough.
I guess you're missing a subfolder there, like in:
Otherwise, this should work:
From my experience,
/xf
can use the wildcard just for names, and not for paths. I don't think it's possible that mix.As a workaround, you may launch
robocopy
twice:According to the documentation at https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy:
So this specifically means that wildcard can be used in the /xf flag but not in the /xd flag.
You can read more about robocopy syntax :