The best way to copy files using built-in commands – Robocopy

I’ve tried countless ways of copying and syncing files in the past, the last being the venerable SyncBack backup program.

Although it served its purpose, these days I’m not a fan of installing more applications than absolutely needed, so I thought I’d explore built-in options again.

I’ve used xcopy previously, but I wanted to try something new. Enter Robocopy…and no, it has nothing to do with this guy:

Robocopy was not created by Robocop!

Robocopy is an excellent command-line tool with about 1 million switches to meet most needs.

So, all I wanted to do was copy a bunch of folders (including empty) across the network, but with the option to try several times if it fails at first, then log the results. This would be setup as a scheduled task to run every night.

This was what I came up with (save in a txt file with a .bat suffix):

::Copy all files from sourcepath to destinationpath using Robocopy
::Last updated on 23/02/2012 by Adam Rush
::(E)mpty folders included in copy
::(R)etry each copy up to 15 times
::(W)ait 5 seconds between attempts
::(LOG) creates log file
::(NP) do not include progress txt in logfile; this keeps filesize down

::Source path
set sourcepath=\\SourceServer\Share

::Destination path
set destinationpath=E:\Destination\Folder

::Log path
set logpath=E:\Logs\Robocopy\

::Include format in log filename
set filename=Robocopy_%date:~-4,4%-%date:~-7,2%-%date:~-10,2%#%time::=-%.txt

::Run command
robocopy %sourcepath% %destinationpath% /E /R:15 /W:5 /LOG:%logpath%%filename% /NP

Pretty simple, but perfect for my needs!



ROBOCOPY C:\SourceFolder D:\DestinationFolder /move /minage:14 (or /minage:20120825)


  1. Marcelina says:

    Nice blog post, sweet blog design and style, stick to the great work

  2. AWESOME PAGE MAN. Helped me out. Thanks and happy Christmas 🙂