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.
Thanks!
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)
The /s option on XCOPY will handle sub-directories (except blank ones).
I would use Robocopy /E /COPYALL /MIR /ETA /LOG:FILE.log /TEE "SOURCE DIR" "DESTINATION DIR"
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: http://technet.microsoft.com/en-us/magazine/2006.11.utilityspotlight.aspx
Try using xcopy instead of copy.
I suggest xcopy /mir [from] [to] if you wish to preserve permissions.
cpx.exe from the utx project supports recursive copying and recursive wildcards for simple and powerful selection of the files to copy.