2

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

alt
  • 497
  • 2
  • 6
  • 15

1 Answers1

1

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

humble.adm1n
  • 151
  • 7
  • 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