Also known as Robust File Copy, Robocopy is a command that is used at the command line to make copies of files and folders. It comes standard with Windows, yet most people have no clue how to work it or that it even exists. For another feature like that, read our article on the 10 Best Epub Readers for Windows.
Although it is more often used by IT professionals, it is definitely easy enough to use for the average home user. Although, it may not be as practical or useful for a home user, at it is best for copying a moving around folders that are large in size. Even so, it is still a great tool to learn and will make your computer skills that much better. So, here is everything you need to start out with using Robocopy, and some examples to get you on your way.
Also Read: 15 Best Command Prompt Tricks, Hacks & Codes
Why Use Robocopy
After reading the definition of what this command does, a common question people ask is why not to just use the copy or xcopy commands. I mean they are much more simple for the average user, and they basically do the same thing, right? Well, the first part of that statement is true, in that those two commands are easier to use. However, there are some slight differences with Robocopy that separates it from the others. Here is these subtle but nonetheless important difference.
- When synching, Robocopy will only copy a file if the file it is being compared to has either a different file size or time stamp. Essentially, this prevents it from not wasting time copying the same exact file. Copy and xcopy will just copy the exact same file, which makes the process take longer and just leads to more clutter.
- It can also be scheduled for a specific time a day for the copying takes places. so that it can copy whenever you need it to not the moment you run the command. This is especially advantageous to people who copy large amounts of folders at a time, which may take several hours. They can just schedule it at night when they aren’t using their computer, so it isn’t slowed down.
- Robocopy also works over network connections so you can now copy over a network easily. This means that if during a copying job, your network disconnects or fails for whatever reason, the job will continue back up once a network is established again. It doesn’t even have to be the same network. This is very beneficial, and another feature that the other commands simply don’t have.
So, you have heard the benefits of using this command, but what are the downsides? Well, here area couple.
- No open files
If you have a file open and try to copy it while using this command, it will not work and you will get an error.
- XP mirroring bug
If you are using a system older than Windows Vista, this command will not mirror properly.
- Unable to copy files
Robocopy is designed strictly to copy folders, not files. If you try to copy a single file it will not work correctly, so make sure it is always in a folder.
Robocopy Syntax and Examples
This is essentially the most important part of understanding Robocopy. You will use all of this syntax to write the command. So, if you know what you want to do, look at the proper command for that action. Like with any programming, syntax is the most imporant part of the process, just like in our article on Python.
None of this will make sense without first showing you what characters and letters mean in this command. Here is a fairly basic list of many commands you may need to use. I will show you some of the most common commands for copy, file selection, and retry options. I left out logging and job options, as they aren’t as important and not necessary for learning the basics of Robocopy. If you want to see a complete list with probably every command you could ever dream of using, check out this article from Computer Hope.
First things you should type
|source||Source Directory (drive:\path or \\server\share\path)|
|destination||Destination Dir (drive:\path or \\server\share\path)|
|file||File(s) to copy (names/wildcards: default is “*.*”)|
|/S||Copy Subdirectories, but not empty ones.|
|/E||Copy subdirectories, including Empty ones.|
|/LEV:n||Only copy the top n LEVels of the source directory tree.|
|/Z||Copy files in restartable mode.|
|/B||Copy files in Backup mode.|
|/ZB||Use restartable mode; if access denied use Backup mode.|
|/EFSRAW||Copy all encrypted files in EFS RAW mode.|
|/COPY:copyflag[s]||What to COPY for files (default is /COPY:DAT).|
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info).
|/DCOPY:T||COPY Directory Timestamps.|
|/SEC||Copy files with SECurity (equivalent to /COPY:DATS).|
|/COPYALL||COPY ALL file info (equivalent to /COPY:DATSOU).|
|/NOCOPY||COPY NO file info (useful with /PURGE).|
File Selection Options
|/A||Copy only files with the Archive attribute set.|
|/M||Copy only files with the Archive attribute and reset it.|
|/IA:[RASHCNETO]||Include only files with any of the given Attributes set.|
|/XA:[RASHCNETO]||eXclude files with any of the given Attributes set.|
|/XF file [file]…||eXclude Files matching given names/paths/wildcards.|
|/XD dirs [dirs]…||eXclude Directories matching given names/paths.|
|/XC||eXclude Changed files.|
|/XN||eXclude Newer files.|
|/XO||eXclude Older files.|
|/XX||eXclude eXtra files and directories.|
|/R:n||Number of Retries on failed copies: default 1 million.|
|/W:n||Wait time between retries: default is 30 seconds.|
|/REG||Save /R:n and /W:n in the Registry as default settings.|
|/TBD||Wait for share names To Be Defined (retry error 67).|
So, they may not mean a lot to you, but there are some basic commands to use in Robocopy. Now, by no means do you need to memorize all of these. They are here for your reference. The key is that you understand how they work, so if you need to you can use them at your disposal.
How to Use
So, I have given you above a lot of great tools for beginning to use Robocopy. However, even if you understand that, you may still be lost on exactly how to start up Robocopy. This is done by opening the command prompt in Windows. Now, there are at least 7 ways to launch the command prompt, each with their own benefits. I believe the easiest way to do it is by pressing the Windows key and the ‘R’ key at the same time, to open up the ‘Run’ window. Once that is opened, type in ‘cmd’ and the command prompt will be open.
Once this is open, begin by typing robocopy/. Doing this will give a lot of options for switches or commands, and it can become a bit confusing. Therefore, you want to tell the computer exactly what you want it to do. So, enter in the proper command for a source, destination or file. The syntaxes for those are listed at the top of the table. This will enact Robocopy, and you will be able to start it.
For another common feature you can use on Windows, read our article title Windows Update Stuck at 0 Percent.
So, What Are Switches?
A term you will hear associated with this command a lot is switches. Switches are simply just copying files from one location to another, or ‘switching’ their destination. I’ve already gone into how to use copy commands, so it should already by familiar to you. Just know that when you see this term in articles, many don’t do a good job at explaining exactly what it means. Just know that it is a fancy word for copying, and you should be fine. A lot of time in computer programming, there are terms that most people don’t know which only confuses them. However, if you take a minute to understand what it means, they usually aren’t difficult. This is no exception.
You may have never heard of Robocopy before this article, but now that you know more about it, you should try it next time the opportunity presents itself. Now, it may not be beneficial for everyone. It is usually employed by large companies with a large amount of important data being moved around, not as popular for individuals at home. Unless you are using it for one of the benefits listed in the first paragraph, it is probably just wiser to stick to using copy or xcopy.
However, it is still a useful tool for you to learn. It may also help you get a better understanding of how computer coding work, which can definitely help you down the road. Once you have mastered Robocopy, it wouldn’t be very difficult at all for you to pick up and learn the Easiest Programming Language.
Yes, there is a lot to be learned still about Robocopy even after you have read this article. Nonetheless, this still provides with a great foundation for understanding this language.
Have any other good pointers on using Robocopy? Leave a comment below and start an insightful conversation.