Windows Robocopy Command Tutorial with Examples To Copy Files In Safe Way

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/windows-robocopy-command-tutorial-examples-copy-files-safe-way/
PINTEREST
PINTEREST
INSTAGRAM

Robocopy or Robust File and Folder Copy application is very popular amongst in Windows system administrators. Robocopy will copy local or given file to the remote or destination location.

Syntax

Copy Folder

The most basic operation with robocopy is copying sources folders to the destination. In this example we will copy directory named mytest to the destination folder yourtest

Copy Folder

Copy Folder

After copy operation some statistics are provided by robocopy

  • Start shows start time of copy operation
  • Source shows source directory
  • Dest shows destination directory
  • Files shows file filter
  • Options shows given options
  • Total shows total files and folders count
  • Copied shows copied files and folders count
  • Skipped shows not copied files and folders

Copy To Remote System

We can also copy file and folders to the remote system. We will provide remote system hostname or IP address before destination path. We can use \\BACKUPSERVER or \\10.5.2.30 to specify remote system.

In this example we will copy source directory named mytest to the remote system with IP address 192.168.122.46 under the path Users\ismail with the named yourtest .

Copy To Remote System

Copy To Remote System

Copy Only Given File Types or Extensions

robocopy provides some filtering features while copying files. We can specify the filenames and extensions we want to copy. This will skip other file named and extensions. We will provide the file name or extension after the destination folder.

LEARN MORE  Apache Log Files

In this example we only want to copy *.txt extension files.

Copy Only Given File Types or Extensions

Copy Only Given File Types or Extensions

We can see from output that only one file is copied but there was more than one file. Copied file name and  byte count is also printed.

Copy SubFolders

By default only first level directories are copied to the destination. If we need to copy all level and subdirectories folders we should enable /S.

robocopy mytest yourtest /S

Copy SubFolders

Copy SubFolders

List Files

There is very useful feature for robocopy where source files are not copied and just listed. This feature can be useful if we want to check existing files and folders. We can use /L option for print list of files and directories.

List Files

List Files

As we can see from output that all files and folders are skipped and not copied.

List Files Recursively

We can merge two options list and recursive to list all level files and folders.

Copy Files Lower Than Given Size

While copying files we can specify the size of files we want to copy. In this example we will copy files those sizes are lower than 1K .  We will use /MAX option for this.

Copy Files Lower Than Given Size

Copy Files Lower Than Given Size

As we can see from results some of files are copied but some of them are left.

LEARN MORE  Linux Log Files or /var/log

Copy Files Higher Than Given Size

The reverse of previous option is /MIN . This  will only copy files higher than given size. In this example we will copy files higher than 1K which is 1000 kilobyte.

Copy Files Higher Than Given Size

Copy Files Higher Than Given Size

Move Files

The default behaviour of robocopy is copying files. Sometimes we may need to move files. This can be done with robocopy too. We will provide /MOV option in order to move files and folders.

Logging

While doing copy and move operations we can also need some logs especially in bulk data operations. We can write log about specified operations with /LOG option. We can also specify the log file name y adding at the end of /LOG option. In this example we will write robocopy operation log to log file named backup.log . This will prevent regular output

Log file can be listed with type command in MS-DOS command line likebelow.

Log

Log

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/windows-robocopy-command-tutorial-examples-copy-files-safe-way/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

1 Response

  1. Catherine Lee says:

    Thanks for this article it was great but I already shifted to GS Richcopy 360. Using Robocopy was a mess, it gave errors one day or another. Now I am satisfied with GS Richcopy 360’s performance. I don’t think I am going back and use Robo. Thanks!

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)