Copy a folder from local to remote machine

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
swift.fire
Posts: 4
Joined: 21 May 2009 05:18

Copy a folder from local to remote machine

#1 Post by swift.fire » 21 May 2009 05:30

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 21 May 2009 09:17

checkout xcopy /?

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

swift.fire
Posts: 4
Joined: 21 May 2009 05:18

#3 Post by swift.fire » 22 May 2009 03:09

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.

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#4 Post by avery_larry » 22 May 2009 12:25

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

Post Reply