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

Can we use robocopy to copy random x number of files from one network share to another in Windows server 2008/ Windows server 2003?

share|improve this question

migrated from Aug 12 '11 at 22:57

This question came from our site for professional and enthusiast programmers.

Depends what you mean by random.

enter image description here

enter image description here

Robocopy doesn't have a "copy some files at random and not others" flag, but it does support wildcard file selection. If you would accept "out of all my files, pick some specific files such that I don't know in advance how many, but I could know and will be the same every time" then you could specify, e.g.

robocopy \\server1\here \\server2\there e*.jpg

If you mean "Pick from a limited few subsets of files, but randomly choose which subset each time", then how about:

robocopy \\server1\here \\server2\there /lev:%random~:1,1%

to choose a random folder depth cutoff each time, or /max:%random% to choose a random filesize cutoff... see The Robocopy Docs for more fun options.

share|improve this answer

If x is a number, not unless you can use the file names for some sort of include rule.
If you just mean the contents of a directory and/or the contents of a directory and it's subfolders, yes.

For network operations remember to use /Z

share|improve this answer

Your Answer


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