![xcopy 命令](https://img-blog.csdnimg.cn/img_convert/cbc5746e392d6edab4750833ce46232c.png)
xcopy 命令
Windows have different tools and commands to copy file, folders and subfolders. Xcopy is one of the most popular copying command. Xcopy comes builtin with all Windows operating systems. In this tutorial we will look different usage types and examples of Windows xcopy command.
Windows具有不同的工具和命令来复制文件,文件夹和子文件夹。 Xcopy是最流行的复制命令之一。 Xcopy随附于所有Windows操作系统。 在本教程中,我们将介绍Windows xcopy命令的不同用法类型和示例。
帮帮我 (Help)
Help about xcopy
command can be get with the following.
关于xcopy
命令的帮助可以通过以下xcopy
获得。
$ xcopy /?
![Help](https://img-blog.csdnimg.cn/img_convert/bf238e50b857b8a16e53e6336c8cb51f.png)
复制文件(Copy File)
Basic usage of the xcopy
command is copying gives file. We will just specify the source file and destination file name and path. We can also specify in relative paths like below.
xcopy
命令的基本用法是复制给定文件。 我们将只指定源文件和目标文件的名称和路径。 我们还可以指定相对路径,如下所示。
$ xcopy poet.txt newpoet.txt
![Copy File](https://img-blog.csdnimg.cn/img_convert/8e9ee652c78e4b805b43bcce5756d2c0.png)
While copying we specify the source as sfile with F
. After copy operation is completed information about the operation is printed like file count source file name etc.
复制时,我们使用F
将源指定为sfile。 复制操作完成后,将打印有关该操作的信息,例如文件计数源文件名等。
复制资料夹 (Copy Folder)
Copy folder is an other useful feature of the xcopy
command. We will copy cygwin64
source folder as new_cygwin64
in the example below.
复制文件夹是xcopy
命令的另一个有用功能。 在下面的示例中,我们将cygwin64
源文件夹复制为new_cygwin64
。
$ xcopy cygwin64 new_cygwin64
![Copy Folder](https://img-blog.csdnimg.cn/img_convert/a1e3cf48fece615d9fa178e40a0db330.png)
递归复制所有文件夹和子文件夹(Copy Recursively All Folder and SubFolders)
In previous example we have given the source folder. The only file contents of the source folder is copied in to the destination folder. We can use /S
option to copy all folders, sub folders and related files recursively like below.
在前面的示例中,我们提供了源文件夹。 源文件夹的唯一文件内容被复制到目标文件夹中。 我们可以使用/S
选项以递归方式复制所有文件夹,子文件夹和相关文件,如下所示。
$ xcopy /S cygwin64 new_cygwin64
![Copy Recursively All Folder and SubFolders](https://img-blog.csdnimg.cn/img_convert/7d15c0a5c451f8eb376ab5429d5973ba.png)
As we can see from screenshot all sub folders and files are copied.
从屏幕截图中可以看到,所有子文件夹和文件均已复制。
开始复制前提示 (Prompt Before Starting Copy)
Another useful feature is prompting before starting copying. This will prevent accidental copying or unwanted overwriting of destination files and folders. We will use /W
option for this feature.
另一个有用的功能是在开始复制之前提示。 这将防止意外复制或意外覆盖目标文件和文件夹。 我们将/W
选项用于此功能。
$ xcopy /W poet.txt newpoet.txt
在每次创建文件之前提示 (Prompt Before Each File Creation)
Another alternative for user acceptation by prompting is prompting in each file creation. This may be a useful feature for some file and folder copy but in bulk operation this is not so useful. We will use /P
option to prompt for each file copy operations like below.
通过提示进行用户接受的另一种方法是在每次创建文件时提示。 对于某些文件和文件夹副本,这可能是有用的功能,但是在批量操作中,它并不是那么有用。 我们将使用/P
选项来提示每个文件复制操作,如下所示。
$ xcopy /P poet.txt newpoet.txt
![Prompt Before Each File Creation](https://img-blog.csdnimg.cn/img_convert/b832eb76b43a115f95436bf6bf6eda2d.png)
复制具有存档属性的文件(Copy Files With Archive Attributes)
While copying files by default some files attributes are not copied. Archive attributes are some of them. We can enable copying archive attributes with /A
option like below.
默认情况下,在复制文件时,不会复制某些文件属性。 存档属性就是其中一些。 我们可以使用/A
选项启用复制存档属性,如下所示。
$ xcopy /A poet.txt newpoet.txt
复制隐藏文件和系统文件 (Copy Hidden and System Files)
Hidden and System files are important part of the operating systems. They are use by Windows operating system internally. If we are making copy on these type of files they are not copied by default. We cna enable copying them with /H
.
隐藏文件和系统文件是操作系统的重要组成部分。 它们由Windows操作系统内部使用。 如果我们要在这些类型的文件上进行复制,则默认情况下不会对其进行复制。 我们可以使用/H
复制它们。
$ xcopy /H poet.txt newpoet.txt
复制特定日期之后更改的文件 (Copy Files Those Changed After Specific Date)
For copy operations those are done same period there are some useful features which will make copy more efficient. We can specify some date and time where these will be used to which files will be copied after that time. In this example we will only copy files those are changed after 01-01-2017
对于在同一时期完成的复印操作,有一些有用的功能将使复印更加有效。 我们可以指定一些日期和时间,在这些日期和时间之后将这些文件复制到这些日期和时间。 在此示例中,我们将仅复制01-01-2017
之后更改的文件
$ xcopy /D:01-01-2017 poet.txt newpoet.txt
翻译自: https://www.poftut.com/windows-copy-operation-xcopy-command-tutorial-examples/
xcopy 命令