Robocopy
Use the built-in Microsoft “robocopy” utility to move or copy files en masse.
Moving files between folders using the Windows Explorer may be convenient for small tasks, but there is a much better way to manage bulk tasks. Robocopy (Robust File Copy) is a command-line file copying tool included in Windows operating system that will run through MS-DOS or PowerShell.
Robocopy is designed for reliable copy or mirroring of entire folders of any size. In the copying process, robocopy will ensure that all NTFS ACLS, attributes, owner information, alternate data streams, auditing information, timestamps and properties are copied except security information unless explicitly requested with /COPYALL switch. The convenience of a graphical user interface is swapped for a much more powerful utility.
Robocopy Syntax
The format for robocopy commands is: robocopy source destination [file [file]...] [options]
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 “*.*”)options
: Add any number of copy and file selection options
A comprehensive list of commands is available on the MSDN website.
To use robocopy, open a command line prompt (either MS-DOS or PowerShell) and enter a command.
Copy all files
To copy all contents including empty directories of the source folder:
robocopy C:\path\to\source C:\path\to\destination
Move all files
To move all contents including empty directories of the source folder:
robocopy C:\path\to\source C:\path\to\destination /e /move
To move all contents excluding empty directories of the source folder:
robocopy C:\path\to\source C:\path\to\destination /s /move
Copy files of a certain type
To copy all contents with a .jpg extension including empty directories of the source folder:
robocopy C:\path\to\source C:\path\to\destination *.jpg
Copy files of a certain size
To copy files larger than 32 MB (33553332 bytes) in size:
robocopy C:\path\to\source C:\path\to\destination /min:33553332
To copy files larger than 32 MB(33553332 bytes) in size:
robocopy C:\path\to\source C:\path\to\destination /max:33553332
Mirror directories
The following command will mirror the directories using Robocopy:
robocopy C:\path\to\source C:\path\to\destination /MIR /FFT /Z /XA:H /W:5
/MIR
specifies that Robocopy should mirror the source directory and the destination directory. Note that this will delete files at the destination if they were deleted at the source./FFT
uses fat file timing instead of NTFS. This means the granularity is a bit less precise. For across-network share operations this seems to be much more reliable – just don’t rely on the file timings to be completely precise to the second./Z
ensures Robocopy can resume the transfer of a large file in mid-file instead of restarting./XA:H
makes Robocopy ignore hidden files, usually these will be system files that we’re not interested in./W:5
reduces the wait time between failures to 5 seconds instead of the 30 second default.
Comments
No comments have yet been submitted. Be the first!