Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Robocoy to transfer a directory and all it's contents. I use the following command as part of a batch file to copy the directories wile ignoring the images subdirectories.

ROBOCOPY C:\source C:\destination /S /L /XD C:\source\images

Most of the images in C:\source\images\ are in subdirectories, named entirely through digits (eg C:\source\images\101\, C:\source\images\102\ .. C:\source\images\2894\) and I want to continue to exclude all and any of these existing or future numerically named subdirectories. However, there is also a subdirectory of C:\source\images that I would like to include in the robocopy command; C:\source\images\static\. I had thought I could use wildcards to exclude directories beginning with 1*, 2* .. 9* but this does not work with the exclude directory (/XD) option.

My immediate thought for a workaround (after having written this all out!) is to include a second and subsequent robocopy command

ROBOCOPY C:\source C:\destination /S /L /XD C:\source\images
ROBOCOPY C:\source\images\static\ C:\destination\images\static\ /S /L

Is there a better way to do this?

share|improve this question

I suspect sometimes you just have to break a problem up into parts, or change the way you organise the folders :-)

Also, if you start being too fancy with exclusions or inclusions, you might find you are destroying performance anyway.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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