Xcopy is a console mode command for the Windows operating system. It is used to copy one or several files and (or) folders from one place to another. She is also a team of the MS-DOS operating system. With many options and the ability to copy entire directories, xcopy is similar to traditional copy, but it has much more features. If even more functionality is required, then the operating system has the robocopy command, which operates with even more parameters.
Syntax
The command line format is as follows:
xcopy source [ receiver ] [/ a] [/ b] [/ c] [/ d [: date ]] [/ e] [/ f] [/ g] [/ h] [/ i] [/ j] [ / k] [/ l] [/ m] [/ n] [/ o] [/ p] [/ q] [/ r] [/ s] [/ t] [/ u] [/ v] [/ w ] [/ x] [/ y] [/ -y] [/ z] [/ exclude: file1 [+ file2 ] [+ file3 ] ...] [/?]
The source determines the name of the file or top-level folder from which the copy will be made. This is the only required parameter to the xcopy command. If the file or directory name contains spaces, it should be enclosed in quotation marks.
The receiver, or target, is a parameter that indicates where the source files or folders should be copied. If it is not specified, the source will be saved in the same directory in which the xcopy command is run. If the name of the destination contains spaces, then it should be enclosed in quotation marks.
/ a
When using this option, only archive files found in the source will be copied. You cannot use / a and / m at the same time.
/ b
This parameter is used to copy a symbolic link, not the one that it refers to. First appeared in Windows Vista.
/from
This option forces xcopy to continue working even if an error occurs.
/ d [: date]
The xcopy command with the / d option followed by a specific date in the MM-DD-YYYY format is used to copy files that were changed on the specified day or later. You can also use this parameter without a specific time value to select only those parts of the source that are newer than documents with the same name in the receiver. Used to perform normal file backups .
/ e
When used alone or with the / s option, the action of the parameter is the same as / s, but also creates empty folders in the receiver, if they were in the source. The / e switch can also be used with / t. This allows you to include empty directories and subdirectories found in the source directory in the directory structure created at the destination.
/ f
This option displays the full path and name of the source and target files.
/ g
Using xcopy with this option, you can copy encrypted files from a source to a receiver that does not support encryption. The key will not work when replicating data from an EFS drive to another encrypted drive of a different type.
/ h
Xcopy does not by default copy hidden or system files, but with this option it can do this.
/ i
This option is used to prevent xcopy from asking if the file or directory is the recipient. If you do not apply this option and copy from the source, which is a directory or a group of files, to a nonexistent destination, the utility will prompt you to specify what the target object is.
/ j
This option copies files without buffering. This feature is useful for very large amounts of data. This xcopy option first appeared in Windows 7.
/ k
The option is used when copying read-only files so that this attribute is saved at the destination.
/ l
This xcopy parameter should be used to display a list of source files and folders, but copying itself is not actually performed. This option will be useful if you are creating a complex command with several keys. In this case, the user will be able to see the expected operation of xcopy.
/ m
This option is identical to the / a option, but after copying, the xsoor command will disable the archive attribute. In all other cases, this attribute will be assigned to all files in the receiver, regardless of whether they had it in the source. You cannot use / m and / a at the same time.
/ n
This option creates files and folders in the receiver using short names. This option applies only when copying to an existing destination on a disk formatted in an older file system, such as FAT, which does not support long names.
/about
Saves owner and access control list (ACL) information in copied files.
/R
When using this option, the user will have to confirm the creation of each file of the target object.
/ q
The option is the opposite of / f. This xcopy option puts execution in silent mode, disabling the on-screen display of information about each copied file.
/ r
This option is used to overwrite read-only files at the destination. If this parameter is not applied when updating data in the receiver, the Access denied message will be displayed and the xcopy command will stop working.
/ s
The option is used to copy folders with files and subdirectories in addition to the contents of the source root directory. Empty directories will not be created.
/ t
This xcopy parameter forces the command to create a directory structure in the receiver, but not to copy any of the files. In other words, folders and subdirectories found in the source will be migrated, but without their contents. Empty directories are not created.
/ u
The option will only copy source files that are already at the destination.
/ v
This option activates the verification of the size of each recorded file to confirm its identity. Verification has been built into the xcopy command, starting with Windows XP, so in later versions of Windows this option does nothing and is included only for compatibility with MS-DOS.
/ w
The parameter is used to display the message “Press any key when ready to being copying file (s)” (“Press any key when you are ready to copy the file (s)”). At the same time, xcopy begins to execute instructions only after confirming the operation by pressing a key. This option does not duplicate the / p switch, which activates copy confirmation of each file.
/ x
This option copies the file audit settings and system access control list (SACL) information. When the / x option is used, the / o switch is executed.
/ y
The option is used so that the xcopy command does not ask for confirmation of overwriting files from the source that already exist in the receiver. Conversely, the / -y option forces rewrite requests. This key may seem redundant, since this behavior of the xcopy command is set by default, but the / y option on some computers can be set in the COPYCMD environment variable, which necessitates this parameter.
/ z
This option allows the xcopy command to safely stop copying when the network connection is lost, and then resume from where it was stopped after the connection is restored. This key also activates the display of the percentage of saving each file during the task.
/ exclude: file1 [+ file2] [+ file3]
This option allows you to specify one or more file names containing a list of search strings that the xcopy command should skip when copying.
/?
When using this key, detailed help will be displayed. Running xcopy /? similar to help xcopy command. The user can save the output, which is sometimes very long, in a file using the redirection operator.
Examples
- xcopy C: \ Files E: \ Files / i
In the above command, the data contained in the source directory C: \ Files is copied to the destination, which is the new Files [/ i] folder on drive E. No subdirectories or files contained in them will be replicated, since it was not used switch / s.
- xcopy "C: \ Important files" D: \ Backup / c / d / e / h / i / k / q / r / s / x / y
In this example, the command is used for backup. This combination of keys successfully replaces data-security software. The specified command can be written to a batch file, and in the task manager assign its daily automatic execution. In this way, regular data backup can be ensured.
The above command line means that xcopy is used to copy all files and folders [/ s], whose date is newer than those already in the receiver [/ d], including empty [/ e] and hidden [/ h], from source C: \ Important files to the target D: \ Backup, which is the directory [/ i]. In addition, there is read-only data that should be replicated [/ r] while maintaining this attribute after writing [/ k]. All access control settings [/ x] must also be saved. Finally, since xcopy must be run in batch mode, there is no need to display information about the copied objects [q], as well as to confirm the rewriting of each of them [/ y]. Stopping when an error occurs is also undesirable [/ c].
- xcopy C: \ Video "\\ SERVER \ Media Backup" / f / j / s / w / z
Here, the xcopy command is used to copy all folders with files contained in the subdirectories [/ s] from the source “C: \ Video” to the target directory “Media Backup” located on the computer’s network under the name SERVER. Since the video is really large in size, buffering [/ j] is disabled to improve the process, and since this happens over the network, it is possible to resume copying when the connection is lost [/ z]. In this case, the user wants to receive a request to confirm that the process has started before xcopy actually does something [/ w], and also wants to see detailed information about which files are written [/ f].
- xcopy C: \ Client032 C: \ Client033 / t / e
In this example, there is a source with a well-organized directory of the current client in C: \ Client032. At the same time, the Client033 folder has already been created for the new client, but the user does not want to copy files, but only the directory structure [/ t], so as not to do this manually. In addition, C: \ Client032 has several empty directories that may be needed for a new client, so you should make sure that they are also played [/ e].
Availability
The command can be called from the command line of all Windows operating systems, including Windows 8, 7, Vista, XP, 98, etc. Also, xcopy is supported by the MS-DOS operating system. It should be noted that the availability of some parameters of the command and its syntax in different operating systems may vary.
Options
On Windows 98 and 95, 2 versions of the command are available: xcopy and xcopy32. However, the last one was never intended to run directly. When performing xcopy on Windows 95 or 98, either the original 16-bit version (in MS-DOS mode) or the new 32-bit version (on Windows) is automatically launched. Therefore, no matter what version of the operating system is available, you must always run the xcopy command, not the xcopy32 command, even if it is available. When executing the first, the most appropriate version will always be used.