Frequent file management operations of friends, not satisfied with the Windows system built-in replication features, because it is too fast. So you use software like FastCopy and teracopy to speed up replication, but do you know that Windows 7 has built-in quick copy capabilities?
This feature is Robocopy, which is a command-line directory Copy command that has been part of the Windows Resource Kit since Windows NT 4.0, and then in Windows Vista, Windows 7, and Windows Server 2008 is used as a standard function. This feature of Windows 7 has also been upgraded-it has been able to support multithreading, which means that replication speed can be greatly improved. It also allows you to create a fully mirrored copy of two file structures without duplicating any unwanted duplicate files, while allowing you to keep all relevant file information, including date and time stamps, secure access control lists (ACLs), and so on. Now let's take a look at the use of this command:
command Syntax : ROBOCOPY source destination [file [file] ...] [Options]
Source: Source directory (drive: \ path or \ \ server \ share \ Path)
Target: Destination directory (drive: \ path or \ \ server \ share \ Path)
Files: Files to be copied (name/wildcard: "* *" by default)
Replication options
/S: Copies subdirectories, but does not copy empty subdirectories.
/E: Copies subdirectories, including empty subdirectories.
/lev:n: Copies only the first n tiers of the source tree.
/Z: Copies files in restartable mode.
/b: Copy files in Backup mode.
/ZB: Use the restart mode, or use Backup mode if Access is denied.
/efsraw: Copies all encrypted files in EFS RAW mode.
/copy: Copy tag:: The contents of the file to be copied (default is/copy:dat). (Copy tag: d= data, a= attribute, t= timestamp). (s= security =ntfs acl,o= owner information, u= Audit information).
/dcopy:t: Copy the directory timestamp.
/sec: Copy files with security (equivalent to/copy:dats).
/copyall: Copies all file information (equivalent to/copy:datsou).
/nocopy: No file information is copied (in effect with/purge).
/secfix: Fix file security for all files, even skipped files.
/timfix: Fixed file time for all files, even skipped files.
/purge: Delete target files/directories that no longer exist in the source.
/mir: Mirrored directory tree (equivalent to/E and/purge).
/mov: Moves the file (deleted from the source after copying).
/move: Move files and directories (deleted from the source after copying).
/a+:[rashcnet]: Adds the given property to the copied file.
/a-:[rashcnet]: Removes the given property from the copied file.
/create: Only create a directory tree and zero-length files.
/fat: Create the target file using only the 8.3 FAT file name.
/256: Turn off Super Long path (> 256 character) support.
/mon:n: monitor source; run again when more than n changes are found.
/mot:m: Monitor source, if changed, run again within M minutes.
/RH:HHMM-HHMM: Run hours – the time at which a new copy can be started.
/PF: Checks the number of running hours on a per-file basis, rather than per-step.
/ipg:n: The spacing between packages (MS) to release bandwidth on low-speed lines.
/SL: Copy the symbolic link against the target.
/MT[:N]: Multi-threaded replication using n threads (default is 8). n must be at least 1, but not greater than 128. This option is incompatible with the/IPG and/efsraw options. Use the/log option to redirect the output for optimal performance.
File Selection Options
/A: Copies only files that have an archive attribute set.
/M: Copy only files with archive properties and reset archive properties.
/ia:[rashcneto]: Contains only files with any given set of properties.
/xa:[rashcneto]: Excludes files with any given set of properties.
/XF file [file] ... : Excludes files that match the given name/path/wildcard character.
/XD directory [Directory] ... : Excludes directories that match the given name/path.
/XC: Excludes files that have changed.
/XN: Exclude newer files.
/xo: Exclude older files.
/XX: Exclude redundant files and directories.
/XL: Exclude orphaned files and directories.
/IS: Contains the same file.
/it: Contains the files that have been adjusted.
/MAX:N: Maximum file size – excludes files larger than n bytes.
/MIN:N: Minimum file size – excludes files less than n bytes.
/maxage:n: Longest file existence time – excludes files older than n days/dates.
/minage:n: Shortest file Presence time – excludes files that are later than n days/dates.
/MAXLAD:N: Maximum last access date – files that have not been used since n are excluded.
/MINLAD:N: Minimum last access date – files that have been used since n are excluded. (If N < 1900 then n = n days, Else n = YYYYMMDD date).
/XJ: Excludes junction points. (usually included by default).
/fft: Suppose the FAT file time (2 seconds granularity).
/DST: Compensates for the 1-hour DST time difference.
/XJD: Excludes the junction point of the directory.
/XJF: Excludes junction points for files.
Retry options
/R:N: Number of retries for failed replicas: default is 1 million.
/w:n: Wait time between two retries: default is 30 seconds.
/reg: Saves/r:n and/w:n in the registry as the default settings.
/TBD: Wait for the definition of the share name (retry error 67).
Logging options
/L: List only – Do not copy, add timestamp, or delete any files.
/x: Reports all the extra files, not just the selected files.
/V: generates verbose output while displaying skipped files.
/ts: Contains the timestamp of the source file in the output.
/FP: Contains the full path name of the file in the output.
/bytes: Print size in bytes.
/ns: No Size – no file size is recorded.
/NC: No category – The file category is not recorded.
/NFL: No file list – The file name is not recorded.
/ndl: No directory list – no record of directory names.
/NP: No progress – The percentage that has been copied is not displayed.
/eta: Displays the expected arrival time of the copied file.
/log: File: Outputs the status to a log file (overwriting an existing log).
/log+: File: Outputs the status to a log file (attached to an existing log).
/unilog: File: Outputs the status to a log file (overwriting an existing log) in UNICODE mode.
/unilog+: File: Outputs the status to a log file (attached to an existing log) in UNICODE mode.
/tee: Output to console window and log file.
/njh: No job header.
/NJS: No Job summary.
/unicode: Outputs the state in UNICODE mode.
Job Options
/job: Job Name: Extract the parameters from the named job file.
/save: Job Name: Saving parameters to a named job file
/quit: Exits after processing the command line (to view parameters).
/NOSD: The source directory is not specified.
/nodd: No target directory specified.
/if: Contains the following files.
What if I don't use so many orders? You can download Microsoft's Robocopy GUI on the official website, which provides an interactive interface that makes it much easier to use:
"Copy Test"
I will be up to 7.9G of "Avatar" HD movie files, through Robocopy, the system built-in replication capabilities and terecopy three respectively copied to the same destination, the copy process is basically no other system operation, the time required to complete the replication and compare
1, using the Robocopy command to copy files, use the maximum thread 128, the time spent 6 minutes 02 seconds
2, using the system built-in file copy function, using a stopwatch to display time of 6 minutes 22 seconds
3, using terecopy Copy, display using 5 minutes 32 seconds
test speed size results : terecopy > Robocopy Command > Built-in copy function, visible robocopy and professional replication software in the speed of a certain gap, and ease of use is relatively poor. However, in the absence of other replication software, the Robocopy command is a good choice to quickly replicate large volumes of files.
--------------------------------------------------------------------"Example"-------------------
Example One: file, how to copy on how to copy
[Implementation effect]
Copy the Plain text (TXT), Word document (DOC), and BMP, TIF image files from the source folder to the destination folder at any time
, which is not what you can do directly with drag and drop in the explorer. [Simple command]
Robocopy d:\work e:\back *.txt *.doc *.bmp *.tif/s
[parameter explanation]
The TXT, DOC, BMP, TIF files under the D:\work file are copied to the E:\back folder, and the other files are not copied. /S is an indication of including
All subdirectories under the empty file, if not, only the files under D:\work are copied, not subdirectories.
[Extrapolate]
(1) If you want to copy all files under the folder including empty folders to the destination folder, the command is: Robocopy
D:\work e:\back/e
/e means that all subdirectories are copied including empty folders.
(2) If you want to copy only two levels of the file (the next level of the file is not copied), enter the command: Robocopy
D:\work e:\back/e/lev:2
/lev:2 represents the level of replication, such as the D:\work\soft (level two) file is copied at the specified level, and
Files under d:\work\soft\office (* * *) are not copied.
example two: Junk files are not copied
[Implementation effect]When backing up data, it is inevitable that *.bak, *.tmp-like junk files will be copied to the destination folder, using
Robocopy can make a clean folder by cleaning out the trash files that we often encounter while copying them.
[Simple command]
Robocopy d:\work e:\back/e/xf *.tmp *.bak
[parameter explanation]
/XF to specify a file type that does not perform a copy operation, the following file name supports wildcard characters. If the argument is/xd, it means that after the exclusion
The specified folder for the polygon.
example Three: Large file I don't want to
[Implementation effect]
When copying, in order to save time, some large files need to be temporarily not copied, and so on when there is idle time, then perform the copy operation is not
Late.
[Simple command]
Robocopy d:\work e:\back/e/max:6000000
[parameter explanation]
Only copy files less than 6000000bytes,/max: Directly after the value, the value unit is byte. If it is/min:1000, then
Copy files that are not less than 1000bytes. Two parameters can be used at the same time to define the scope of the copied file size.
example four: As long as the files modified this week
[Implementation effect]
What documents are processed this week? Did you edit those files? Copy these modified documents to a folder, and then take a good look.
A moment. This example is to copy the new or modified TXT, DOC, XLS, PPT, and other documents in D:\work in the last seven days to E:\look
Directory.
[Simple command]
Robocopy d:\work e:\look/s *.txt *.doc *.xls *.ppt/maxage:7
[parameter explanation]
/maxage: Represents the furthest modification time, and the modified time is older than this file will not be copied. /maxage: After the number can be received
, can also meet the date, the number is less than 1900 to indicate the number of days, otherwise you have to use YYYYMMDD to represent the specific date
If/maxage:20040210 indicates that files modified after February 10, 2004 are allowed to replicate. The parameters corresponding to it
Is/minage, which represents the most recent modification time, than this time the new file will not be copied.
[Extrapolate]
Robocopy d:\work e:\look/s *.txt *.doc *.xls *.ppt/maxage:7/minage:1
It means that files modified in the last seven days except today are allowed to be copied.
Compared to the modified time, the last access time,/maxage refers to the furthest access time, older than this time the file will not be copied.
/minage refers to the most recent access time, and new files will not be copied at this time.
example Five: My document Platoon station
[Implementation effect]
When you copy in the example above, all the documents will have their own path information, and the document will copy the folders they are stored in.
This brings a lot of inconvenience to our browsing view, we have to click the multi-level folder to see the file, can you copy all the documents directly to
Under a folder? This needs to be implemented with Xxcopy.
[Simple command]
Xxcopy d:\work e:\look/s/in*.txt/in*.doc/sg/yy/da:2004-02-02/db:2004-02-
10/da:1997-01-01
[parameter explanation]
This command copies the TXT, doc files generated from the d:\work from February 2, 2004 to February 10 directly to the E:\look directory.
Without creating a new subfolder, open E:\look to see all the files. The syntax parameters of Xxcopy and robocopy are still very different, the table
When specifying a file type, Xxcopy uses/in*.* to represent the date/da the specified time,/db the
expressed as YYYY-MM-DD.
In addition,/SG indicates that the file is copied to the same folder, and/yy indicates that it is automatically considered yes in all areas where the user is required to answer
User intervention is not required during the row.
example six: Full cloning
[Implementation effect]
We generally take the replication method by default is incremental replication, that is, according to the size of the file, modified time to the source folder contents to the target
Folder replication, over time, the target folder may have a large number of files and folders that have already been deleted and useless in the source folders.
If you want to make the backup exactly the same, delete the files that exist in the destination folder but not in the source folder when you copy.
[Simple command]
Robcopy d:\work E:\look/mir
[parameter explanation]
The role of/mir is equivalent to/purge/e,/purge, which indicates that files (folders) that are not in the source folder are cleaned up. Pass
This command ensures that the source and destination folder structures are exactly the same as the files. This is useful when creating a mirrored backup.
example seven: moving Files
[Implementation effect]
What we're talking about is copying, and if we're going to move the folder to the target folder, how do we do it?
[Simple command]
Robocopy D:\work e:\look/move/e
[parameter explanation]
Where/move represents the move.
Example Eight: I just need a folder skeleton
[Implementation effect]
The author's work needs to create and organize a large number of folders periodically, each time the folder structure, but the file is not the same.
If it was before, it would have to be a simple repetition of the production, and now it is not necessary. Robocopy and xxcopy can make it easy for you
Copy the folder structure.
[Simple command]
Xxcopy d:\work e:\mystruct/t/yy/dl3
[parameter explanation]
Copy the D:\work three-tier folder structure to E:\mystruct. Where/T represents the creation of a folder structure,/DL3 represents the replicated
The folder structure is * * *, the number can be entered by itself, if not, the entire folder structure is established by default.
Robocopy Creating a folder is a bit cumbersome, and the/create parameter not only creates the structure, but also creates a folder for all files under the
0 bytes file, not the real structure, we had to go pifo the sword.
Robocopy d:\work e:\mystruct/e/lev:3/minage:19000101
Specifies a time for Robocopy to create a file, because there is a parameter/E function, although no file meets the requirements (your machine
No earlier than January 1, 1900 files), but Robocopy will still be faithful to create the folder, so that the build folder is reached
The purpose of the structure. In addition,/lev:3 represents the level of the replicated folder, which can also be entered on its own.
example nine: Hidden files I don't want to
[Implementation effect]
By default, hidden files are not displayed, but during replication, they are also copied along with the folder. Don't
Can these hidden files be excluded from the replication scope?
[Simple command]
Robocopy d:\work e:\back/e/xa:h
[parameter explanation]
Robocopy supports manipulation of attributes. The above command will copy all files in the source folder, but all have hidden properties
will not be copied. /xa:h that will have a hidden attribute excluded from the replication scope, which corresponds to the/ia, which means that it includes only the
The execution action that owns the specified property. The properties are r: Read-only, A: archive, S: System, H: Hidden, and several other options.
[Extrapolate]
(1) In addition, Robocopy also have/a+,/a-and other parameters to manipulate the file attributes, respectively, after the file is copied to add the file
Add or remove a property.
Robocopy D:\work E:\back/ia:rs
Indicates that only files with read-only and system properties are copied.
(2) Robocopy c:d:/-a:rsh
After copying files to the D drive, the read-only, system, and hidden properties of the copied generated files are removed for easy viewing and modification.
Example ten: NTFS Permissions follow along
[Implementation effect]
When using Windows 2000, Windows XP, when multiple users use a single computer or when managing a server, it is often necessary for a folder
Specifies the user access and modification permissions (1, which requires partitioning to NTFS). However, it is not possible to retain our settings in the normal way of copying
permissions, which in the case of a server backup means we have to reset the user permissions. However, Robocopy allows us to copy the file
Properties, user rights, and owners can be copied to the destination folder.
Backup two neighbors wonderful 5 cases-robocopy and xxcopy full Mastery
[Simple command]
Robocopy d:\work e:\back/e/copyall
[parameter explanation]
/copyall equals/copy:datsou, which means that information from all source folders is copied to the destination folder, where D: File data,
A: File attributes, T: Time information, S: Permission information, O: Owner information, U: Audit information.
[Extrapolate]
If the permissions of the source folder are modified and you need to update the permissions of the target folder as well, we do not have to repeat the replication, just enter
Robocopy D:\work E:\back/is/copy:sou
If there is no/copy parameter, the default is/copy:dat, and there is no information for the following three items.
Example 11: Centrally backing up to a file server
[Implementation effect]
You want to be able to back up the data to a file server every day to avoid data loss.
[Simple command]
Robocopy d:\work \ctips_serverarticlesshare/e/copyall
[parameter explanation]
As you can see, Robocopy fully supports copy of File server shared folder data.
[Extrapolate]
(1) If we create an environment variable, such as defining%databack% as \ctips_serverarticles\back, then just lose
into the corresponding command: Robocopy d:\work%databack%/e/copyall can back up all the files under D:\work to
Under the \ctips_serverarticles\back. Of course, if the \ctips_serverarticles\back space is not enough, just change the environment
The value of the variable to other folders, such as \ctips_serverarticles Ewback, the above command can be copied to the new data without changing
In the folder.
(2) If you only want to back up the data to a shared folder with your machine name in the shared folder, using Xxcopy will be more
Convenient: xxcopy d:\work \ctips_serverarticles/$HOST $/e/yy where/$HOST $ represents your machine name, as your
The machine name is Ctips_syj, which will copy the files under the D:\work folder to the \ctips_serverarticles\ctips_syj folder.
Under If your machine name is CTIPS_MLB, then you can copy the files under the D:\work folder to
The \ctips_serverarticles\ctips_mlb folder. Since the name of the machine in the LAN is not the same, the execution of the above command
You can guarantee that the data will not be copied to the same folder.
example 12:1 moving on backup
[Implementation effect]
Some of the work content is very important, need to pay attention to the backup, but where do we have such a good memory and patience? This matter, also
Give it to Robocopy to do it. Robocopy can always monitor the folder to be backed up, as long as the folder is modified to a certain time and program,
Robocopy will start the backup immediately. It will always monitor the folder unless the user terminates it himself.
[Simple command]
Robocopy d:\work e:\back/e/copyall/mot:1/mon:2
[parameter explanation]
The above command indicates that all the information in the folder is copied to the destination folder and monitored. After you execute this command, the command Prompt window 2
is shown. Once the time is over a minute and the source folder has at least 2 or more modifications, Robocopy will automatically start another process
, perform the previous backup operation. Robocopy can monitor the source folder structure, file and folder name, size, and last modified time, in this
, even when information such as properties and permissions are modified, Robocopy is also remembered as the number of changes.
Backup two neighbors wonderful 5 cases-robocopy and xxcopy full Mastery
/mot followed by the time (minutes), refers to the robocopy the shortest time to perform the operation,/mon followed by the minimum number of file modifications
。 During the monitoring process, the time and the number of changes are automatically recorded, and only when the above two conditions are met, does the Robocopy start executing
, when execution is complete, both data is automatically zeroed and the Monitoring folder is restarted, unless the user closes the command prompt window or presses
The Ctrl+break key.
[Extrapolate]
If you want to monitor and back up the appropriate folder when you turn it on, you can put the above command in the Startup group.
Example 13: Less time not backed up
[Implementation effect]
The process of replication always consumes system resources, and if you can set up to start copying backups when you are not on your computer, it will be convenient to
Many. For example, 5:50 every day, hope after work, arrive 6 o'clock, Robocopy automatically start to back up the corresponding data.
[Simple command]
Robocopy d:\work e:\back/e/rh:1800-1830
[Extrapolate]
After running, the copy operation will wait until the specified time starts (3). wherein, the RH format is/RH:HHMM-HHMM, specifying
Robocopy the beginning of the time period, the copy will be paused outside of this time period. The time is 24-hour format, 4 digits long, from 0000 to
2359, and two numbers cannot be the same.
Backup two neighbors wonderful 5 cases-robocopy and xxcopy full Mastery
Example 14: Scheduled Task backup
The above to time backup, monitor folder backup method, each reboot system will have to re-execute the above command, is not enough
Smart, and if you can work with Windows ' scheduled tasks, all the problems will be solved. To be automatically called at 10:00 every day.
Robocopy Start monitoring the backup folder as an example, say that the scheduled task and Robocopy together.
First step: Create a new BAT file
Create a new batch file Autobak.bat, enter the following command
Robocopy d:\work e:\back/e/copyall/mot:1/mon:2
Step Two: Create a scheduled task
Select start → settings → control Panel, and double-click the Task Scheduler icon. Drag and drop the Autobak.bat batch file to the Task Scheduler
window, and then double-click the newly generated Autobak.bat icon to set its properties in the pop-up window.
Step three: Set the start time
Switch to the Schedule tab, click the Scheduled Task drop-down list box, select Daily, start time set to
10:00, click Advanced to set the starting Date (4).
With the above settings, the machine automatically backs up and monitors folders automatically when the time is set to run the batch file.
Backup two neighbors wonderful 5 cases-robocopy and xxcopy full Mastery
Example 15: Clean files are also good
In addition to the general replication functionality, Xxcopy also has the File Cleanup feature, which allows you to quickly clean up your hard disk with unwanted files. The following command
Clears the files and folders, first create a test folder and then manipulate the folders before you know what to do.
1. Clear all useless files
Xxcopy d:\work*.tmp/s/h/yy/rs
/RS indicates that the specified file is deleted directly from the source folder without copying, and/h indicates the hidden and system files are specified.
2. Clear the folder
Xxcopy C:emp/rmdir/db:2002-01-01/yy
Delete the C:emp folder that was modified before January 1, 2002.
3. Delete Empty folders
Xxcopy c:emp/rmdir/sz:0/yy
Delete all empty folders under C:emp,/sz:0 specify a file size of 0 (clip).
4. Delete a 0-byte file
Xxcopy c:emp*.*/sz:0/s/h/yy/rs
With the combination of the above four ways, we can easily organize the files and folders.
Finally, there are a few tips to tell you that hopefully it will help you to better use Xxcopy and Robocopy.
★ Turn command into a task
In Robocopy Add "/save: Task Name" can record the current operation as a task file, through the "/job: Task Name" can be easily adjusted
, you don't need to enter a long list of commands. This task file can be edited with a plain text editor, such as Notepad.
★ Record the Copy backup process
By default, the Robocopy process is only displayed at the command prompt, and we can let it output the process as a TXT file.
Add "/log: File name. txt".
Using the Robocopy command