Wednesday, 22 October 2008

Robustly copying large directories on Windows

When my Windows XP installation self-destructed, I was fortunate that it was only the system that was corrupted; my data was still accessible.  Compared to rebuilding the system, copying the data from the old, dodgy disc onto the new disc seemed like it should be simple.

Of course, it was not to be: between the virus scanner complaining that some of the Linux scripts I had checked out were viruses, and Explorer not liking the length of some of the paths, I gave up on doing it the obvious way.

Instead, I fell back to good old xcopy.  After a bit of googling, here's the command line I ended up with:
C:\>xcopy G:\builds E:\builds /E /C /Q /H /R /K /X /Y
957918 File(s) copied

I don't know whether all these flags are necessary, but they did seem to work!  The intention is to copy as many attributes of the original files as possible.

If the directory doesn't exist, xcopy will ask whether you wanted to create a file or a directory.  I imagine if you say "file" it won't work too well.
C:\>xcopy G:\Data E:\Data.old /E /C /Q /H /R /K /X /Y
Does E:\Data.old specify a file name
or directory name on the target
(F = file, D = directory)? d
1702 File(s) copied

No comments:

Post a Comment