Page 1 of 1

Copy a folder from local to remote machine

Posted: 21 May 2009 05:30
by swift.fire
I have to copy o folder(with subfolders and files) os size ~ 5GB. My requirements:
1) The batch should not stop even if it encounters an error(like unable to copy a particular file.)
2) should be able to log the error.
3) Should also show that the copy is sucessful ie the content of source and destination are same.

Any help will be appreciated.

Thanks

Posted: 21 May 2009 09:17
by avery_larry
checkout xcopy /?

You'll need /e /c /v -- maybe /h -- and probably some type of output redirection for the logging using > and 2>

Posted: 22 May 2009 03:09
by swift.fire
I would like to create a log of the files which failed to copy. How do I implement it through a batch.

I want something like this
do copy
{
if(copy sucessful)
{log the file names}
else
{log the file names}
}

Bacally I want to differentiate between copy and failed to copy scenarios.

Posted: 22 May 2009 12:25
by avery_larry
the /f switch will give the full path.

I'm pretty sure that stdout will give you the successful copies, and stderr will give you failures. You can redirect stdout with the typical ">" redirect, which is actually "1>" for stdout (stream 1). You can redirect stderr (stream 2) with "2>" like this:

xcopy /f /e /c /h /v *.* path:\destination >success.txt 2>errors.txt

You'll have to test it to make sure it actually works like that.

Ted