xcopy 命令_带有示例的Xcopy命令教程的Windows复制操作

xcopy 命令

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
Help
帮帮我

复制文件(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
Copy File
复制文件

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
Copy Folder
复制资料夹

递归复制所有文件夹和子文件夹(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
Copy Recursively All Folder and SubFolders
递归复制所有文件夹和子文件夹

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
Prompt Before Each File Creation
在每次创建文件之前提示

复制具有存档属性的文件(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
LEARN MORE  How to Use 'fuser' to Match User and Process
了解更多信息如何使用“ fuser”匹配用户和流程

翻译自: https://www.poftut.com/windows-copy-operation-xcopy-command-tutorial-examples/

xcopy 命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值