Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 need to copy a full directory tree (aka recursive copy) with a bat files on windows. On *nix systems I use the -R argument on the copy command, like so:

cp -R fromDir toDir

and that did the job. I could not find anything similar in the windows "man pages" of the copy command.


share|improve this question
Windows no longer has anything similar to man. DOS did have fairly good help files but they've been abandoned. However, most Windows command line programs will have some level of help built in, which is accessed by using /? as a parameter, similar to --help in nix. – John Gardeniers Sep 30 '09 at 21:35
up vote 5 down vote accepted

The /s option on XCOPY will handle sub-directories (except blank ones).

share|improve this answer
I would also add the /e switch to capture empty direcoties /v to verify the file /x to copy ownership/acl and audit setting and /k to copy attributes /z if over the network for restartable mode – Zypher Aug 26 '09 at 13:54
/s/e/c/h/r/k/y are my standard xcopy switches, memorised at this point in time. /x does audit settings as well as ACL, if you want ACL only include /o in the mix. – Le Comte du Merde-fou Aug 26 '09 at 14:06
Interestingly enough in Vista, xcopy prints a "use robocopy instead" message indicating xcopy is deprecated... but in Windows 7 xcopy does not print this message anymore... I'm not sure I'm annoyed or relieved - two strong copy commands seems like one too many, oh well ^^ – Oskar Duveborn Aug 26 '09 at 14:28

Copy doesn't handle recursion. Use robocopy instead. On Windows 2008 it's already there and in the Path. On Windows 2000 and 2003 it's in the resource kit. Flags you'll want are /S /Z /ETA.

/S recursion /Z restartable node /ETA tell me how long the current file will take (optional)

share|improve this answer


Example: robocopy.exe /E /COPYALL /MIR /ETA /LOG:C:\copy.log /TEE "C:\SourceDirectory\\" "C:\DestinationDirectory\\"

/E: copy subdirectories, including Empty ones.
/COPYALL: Will copy all security flags and timestamps on files
/MIR: Will make an exact copy of the source. So if you copy it once, and then copy over a second time, it will process deletes along with new files.
/ETA: show Estimated Time of Arrival of copied files.
/Log: Creates a log file
/TEE: output to console window, as well as the log file.

There are many different options for robocopy if you do the /? for more advanced usage.

You can also use the GUI version:

share|improve this answer

Try using xcopy instead of copy.

share|improve this answer

I suggest xcopy /mir [from] [to] if you wish to preserve permissions.

share|improve this answer

cpx.exe from the utx project supports recursive copying and recursive wildcards for simple and powerful selection of the files to copy.

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.