Robocopy and XCopy are two command line tools frequently used in file transfers for Windows. XCopy is included in most versions of Windows. However, XCopy has been less used as Robocopy is distributed with both Windows 7 and Windows Vista. Also, Robocopy is part of the Windows Resource Kit. For all types of mass file copying, both are useful programs, Robocopy has several options that make your job easier.
Unlike XCopy, Robocopy is used to mirror or synchronize directories. Instead of copying all of the files from one directory to another, Robocopy will be able to check the destination directory and delete files no longer in the main tree. Also, it checks the files in the destination directory against the files to be copied and does not waste time copying unchanged files.
Apparently, Robocopy supports file and directory monitoring with the “/MON” or “/MOT” commands. “/MON:n” copies the file to the destination with ‘n’ or more changes, while “/MOT:m” will check the file every “m” minutes for any changes, then copies it when there are. In fact, this is similar to saving a file periodically while working on it, but more efficient. While XCopy has no monitoring support.
According to the research, both Robocopy and XCopy have support for copying over the archive attribute on files. However, Robocopy brings this a step further. It supports copying over all attributes including security, owner, timestamps, and auditing info. Those additional attributes help to maintain a correct directory structure, especially when copying as an administrator.
If you use the “Run Hours” (/RH) option with Robocopy, it will offer you to set when copies should be done rather than the time of the command as with XCopy. This automation is most useful for creating daily backups or for large batch jobs which will take some time but require no interaction. You have to note that the robocopy.exe process is going to be present in the task list since it checks the clock to view when to copy. Also, Robocopy supports logging with the /LOG:file option and retrying defaults are one million tries, 30 seconds apart for further automation.
Based on the explanation above, now you may can conclude which is the best performance between Robocopy and Xcopy.
Apparently, you also come here to find out some information related to Batch files and you want to compare it with them; Robocopy and Xcopy. If so, let us continue reading the following text.
COPY AND PASTE WITH A BATCH FILE
Easily, you are able to copy and paste files and data by using the Windows clipboard manually using a keyboard or mouse. But, you are also able to automate copying and pasting by using the Windows command line called “cmd.” If you are writing a batch file to copy files, you are able to use the traditional “copy” command or a newer tool named robocopy. There are also the tools to let you store text to the Windows clipboard from a Batch File or PowerShell script.
UNDERSTANDING BATCH FILES
You have to know that a Windows batch file is a specific type of script which is able to be run by the Windows command line tool, known as cmd. It is essentially a list of commands that you can type into the command prompt all combined into one file in order to automate a particular task. Usually, Batch files end with the extension .bat. In fact, the files have been around since the days of MS-DOS, Microsoft predecessor to Windows. For some aims, it creates more sense to use another, more powerful scripting language instead of utilizing a batch file. You are able to use the newer Windows PowerShell environment that has access to Microsoft’s .NET programming framework, a third-party, cross-platform scripting tool such as Python or Node.
BATCH FILE TO COPY FILES/FOLDERS
If you want to copy files from one place to another in a Batch File, you need to have cmd copy and paste the file. Please use the command called “Copy.” Usually, you are able to put the word copy on one line, followed by the original file and where you want it copied, such as “copy C:\Example\Example.txt C:\Example2\Example2.txt.” You have to note that the folder you are copying to must already exist or you are going to face an error message. Do not forget to use the built-in command “mkdir” or “md” to make a folder if you need to do so.
Copy takes several special arguments, such as “/y” to skip prompts to verify you wish to overwrite an existing file. You will be able to check the documentation for the version of copy on your computer by typing “copy /?” at the command line.
ROBOCOPY IN A BATCH FILE
Also, you are able to use a program built in to Windows named Robocopy to transfer files. It works similarly to the copy command however has more features, including to copy attributes of the file like timestamps or to copy entire folders and their contents. For instance, you are able to type “robocopy C:\Example1\ C:\Example2 /e /copyall” to copy Example 1 and its subfolders to Example 2 while preserving all file attributes. Please check the robocopy documentation from Microsoft to view the full list of options.
BATCH FILE TO COPY DATA
If you wish to copy actual data to the Windows clipboard, you are able to use the command “clip.” To copy data from a file, please type “clip < filename” in your batch file. To send output from another command to clip, you have to type “command | clip.” This is going to store the data on the Windows clipboard, overwriting any other data which is there. For your information, you cannot directly paste from the Windows clipboard by using a batch file. However, you are able to use a PowerShell script and the function “Get-Clipboard” to access the clipboard contents. The corresponding command “Set-Clipboard” allows you to overwrite what’s already there, similar to clip.
On my daily job, I am a software engineer, programmer & computer technician. My passion is assembling PC hardware, studying Operating System and all things related to computers technology. I also love to make short films for YouTube as a producer. More at about me…