I am trying to copy bulk files from one directory to another. I have a list of extensions am interested such as pdf, jpg, CSV, etc. I want to exclude the files if a sub-folder contains a certain name.
This code copies all the files and folders
ROBOCOPY A:\OLD\ C:\Users\AG\Documents\ /S *.doc *.docx *.pdf *.xlsx *.xlsm *.xlsb *.ppt *.pptx *.xls *.csv *.ne2 *.txt *.JPG
But I want to exclude all the sub-folders with a certain name e.g. BACKUP at many levels, below are just some examples
A:\OLD\2011\BACKUP
A:\OLD\2012\SHARED\BACKUP
A:\OLD\2012\BACKUP\
I tried using a wildcard in the exclude option to robocopy but is not working
ROBOCOPY A:\OLD\ C:\Users\AG\Documents\ /S *.doc *.docx *.pdf *.xlsx *.xlsm *.xlsb *.ppt *.pptx *.xls *.csv *.ne2 *.txt *.JPG
/XD *BACKUP*
How do I get this to work or an alternative? Please help.