Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Batch file to copy files from one server to other server

Posted on 2015-01-14
Last Modified: 2015-01-14
I need a batch file that can copy all the files in a folder from one server to other server
Question by:Svlss
  • 5
  • 3

Expert Comment

by:Trenton Knew
ID: 40549067
robocopy [SOURCE] [DEST] /E /COPY:DATSO /W:3 /R:3

Author Comment

ID: 40549077
Trenton I tried your suggestion but it dint work how can we edit to write results to a file

robocopy D:\Test \\server\sharedfolder /E /COPY:DATSO /W:3 /R:3

Author Comment

ID: 40549087
I tried this and it worked but I want the batch file to write logs. how can I do that ?

copy D:\Test\*.*  \\server\sharedfolder
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center


Expert Comment

by:Trenton Knew
ID: 40549093
you want to write the robocopy command output to a file? Two ways to do this.  You can direct ALL output to the file (no screen output), or output to both the file and the screen.

robocopy D:\test \\server\sharedfolder /E /Copy:DATSO /W:3 /R:3 /V /LOG:logfilename /TEE

/E copies all directories, even empty ones
/W:3 waits 3 seconds between failures
/R:3 limits retries to 3 times (default is a million)
/V verbose output
/TEE spits output to the  filename under /LOG and to the screen
/COPY: tells robocopy what to copy.  the important parts here are (D)ata (A)ttributes (T)imestamps.  (O)wner and (S)ecurity are important, but can sometimes trip you up.

Expert Comment

by:Trenton Knew
ID: 40549094
what are you trying to log?

Author Comment

ID: 40549096
I am trying to log the results if  the files uploaded successfully or if the upload failed

Expert Comment

by:Trenton Knew
ID: 40549115
ok, well robocopy with the /log flag will do that...

/LOG:filename for new file
/LOG+:filename to append to existing logfile

Accepted Solution

Trenton Knew earned 500 total points
ID: 40549121

robocopy D:\test \\server\share /E  /LOG+:robocopy.log /TEE /V

Open in new window

Also, add /XO if you do not need to recopy files that have not been modified

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question