1

How can I have robocopy exclude any file with a in the filename, unless it also has b?

EG Exclude

foo-a.txt
foo-a-c.txt

Include

foo-a-b.txt
foo-a-b-c.txt

The /XF switch looks like it's the most promising, but I don't know how to construct the wildcard for anything more than basic * style globs.

/XF file [file]... :: eXclude Files matching given names/paths/wildcards.

Doing something like robocopy /mir c:\test\source\ c:\test\dest\ /XF "*a*" results in no files being copied

  • @EEAA I've updated the question with what I've tried and where I'm struggling. – alt Apr 24 '17 at 22:22
0

Unfortunately Robocopy has no explicit Include operator or a (known to me) options to reverse the exclude. But you can provide wildcards for the file name which should do what you might want.

Try:

robocopy <source> <dest> "*a-b*" [options] 

Regards

  • I'll accept this answer as it's helpful, and the fault is with the software, not your response ;) – alt Jun 15 '17 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.