robocopy复制文件

您所在的位置:网站首页 windows的复制命令 robocopy复制文件

robocopy复制文件

2024-03-10 06:33| 来源: 网络整理| 查看: 265

robocopy复制文件

robocopy复制文件

Robocopy or Robust File and Folder Copy application is very popular amongst Windows system administrators. Robocopy will copy the local or given file to the remote or destination location.

Robocopy或“可靠的文件和文件夹复制”应用程序在Windows系统管理员中非常流行。 Robocopy会将本地或给定文件复制到远程或目标位置。

robocopy功能 (robocopy Features)

The command robocopy provides very useful features for files copying over network. Below we will list some of them.

robocopy命令为通过网络复制文件提供了非常有用的功能。 下面我们将列出其中一些。

Resume Interrupted Copy when the network or remote host is down during a copy the copy operation can resume where it left.

Resume Interrupted Copy当网络或远程主机在复制过程中关闭时,复制操作可以从其离开的地方继续进行。

Preserve File Attributes and timestamp of the copied file where owner and audit information is also preserved.

Preserve File Attributes and timestamp复制文件的Preserve File Attributes and timestamp ,其中还保留所有者和审核信息。

Ability To Update Copied File Attributes and Timestamps of the copied files and folders which will set to the latest date and time.

Ability To Update Copied File Attributes and Timestamps已复制文件和文件夹的Ability To Update Copied File Attributes and Timestamps ,这些Ability To Update Copied File Attributes and Timestamps将设置为最新日期和时间。

Administrator Owned File Copy is supported with the option /B.

/B选项支持Administrator Owned File Copy 。

Mirror Mode is provided to sync or mirror given files and folder or directory updated files will be updated and deleted files will be deleted on the target.

提供了“ Mirror Mode以同步或镜像给定的文件,并且将更新目标上的文件夹或目录更新的文件,并删除已删除的文件。

Skip Allready Existing Files by checking size and timestamp information and comparing it to the source and target.

通过检查大小和时间戳信息并将其与源和目标进行比较,从而Skip Allready Existing Files 。

Progress Bar will shown current copy operation graphically.

Progress Bar将以图形方式显示当前的复制操作。

Multi-threaded copying which will allow copy, mirror multiple files and directories at the same time which will decrease the complete copy operation time.

Multi-threaded copying允许同时复制,镜像多个文件和目录,这将减少完整的复制操作时间。

robocopy命令语法 (robocopy Command Syntax)

The general syntax of robocopy command is like below.

robocopy命令的一般语法如下所示。

robocopy SOURCE DESTINATION FILE OPTIONS SOURCE is the source file or directory we want to copy

SOURCE是我们要复制的源文件或目录 DESTINATION is the destination file or directory we want to copy

DESTINATION是我们要复制的目标文件或目录OPTIONS are different features or behaviors we want to use like recursive, verbose, extension filter, etc.

选项是我们要使用的不同功能或行为,例如递归,详细,扩展过滤器等。 复制指定的文件夹 (Copy Specified Folder)

The most basic operation with robocopy is copying sources folders to the destination. In this example, we will copy the directory named mytest to the destination folder yourtest

robocopy最基本操作是将源文件夹复制到目标位置。 在此示例中,我们将名为mytest的目录复制到目标文件夹yourtest

> robocopy mytest yourtest Copy Folder Copy Folder 复制资料夹

After copy operation, some statistics are provided by robocopy

复制操作后, robocopy提供了一些统计信息

Start shows start time of copy operation

Start显示复印操作的开始时间

Source shows source directory

Source显示源目录

Dest shows destination directory

Dest显示目的地目录

Files shows file filter

Files显示文件过滤器

Options shows given options

Options显示给定的选项

Total shows total files and folders count

Total显示文件和文件夹总数

Copied shows copied files and folders count

Copied显示复制的文件和文件夹数

Skipped shows not copied files and folders

Skipped显示未复制的文件和文件夹

LEARN MORE  About Plugins Of Firefox 了解有关Firefox插件的更多信息 从本地系统复制到远程系统(Copy From Local System To Remote System)

We can also copy a file and folders to the remote system. We will provide a remote system hostname or IP address before the destination path. We can use \\BACKUPSERVER or \\10.5.2.30 to specify the remote system.

我们还可以将文件和文件夹复制到远程系统。 我们将在目标路径之前提供一个远程系统主机名或IP地址。 我们可以使用\\ BACKUPSERVER或\\ 10.5.2.30来指定远程系统。

In this example, we will copy the source directory named mytest to the remote system with IP address 192.168.122.46 under the path Users\ismail with the named yourtest .

在此示例中,我们将名为mytest的源目录复制到IP地址为192.168.122.46的远程系统上,并位于路径Users\ismail ,且名为yourtest 。

> robocopy mytest \\192.168.122.46\Users\ismail\yourtest Copy To Remote System Copy To Remote System 复制到远程系统 仅复制给定的文件类型或扩展名(Copy Only Given File Types or Extensions)

robocopy provides some filtering features while copying files. We can specify the filenames and extensions we want to copy. This will skip other file names and extensions. We will provide the file name or extension after the destination folder.

robocopy在复制文件时提供了一些过滤功能。 我们可以指定要复制的文件名和扩展名。 这将跳过其他文件名和扩展名。 我们将在目标文件夹之后提供文件名或扩展名。

In this example, we only want to copy *.txt extension files.

在此示例中,我们只想复制*.txt扩展名文件。

> robocopy mytest yourtest *.txt Copy Only Given File Types or Extensions Copy Only Given File Types or Extensions 仅复制给定的文件类型或扩展名

We can see from the output that only one file is copied but there was more than one file. Copied file name and byte count is also printed.

从输出中我们可以看到仅复制了一个文件,但是有多个文件。 复制的文件名和字节数也会打印出来。

复制子文件夹 (Copy SubFolders)

By default, only first level directories are copied to the destination. If we need to copy all level and subdirectories folders we should enable /S.

默认情况下,仅将第一级目录复制到目标。 如果需要复制所有级别和子目录文件夹,则应启用/S

> robocopy mytest yourtest /S Copy SubFolders Copy SubFolders 复制子文件夹 列出文件(List Files)

There is a very useful feature for robocopy where source files are not copied and just listed. This feature can be useful if we want to check existing files and folders. We can use /L option to print the list of files and directories.

robocopy有一个非常有用的功能,其中的源文件不会被复制,而是被列出。 如果我们要检查现有文件和文件夹,则此功能很有用。 我们可以使用/L选项来打印文件和目录的列表。

> robocopy mytest yourtest /L List Files List Files 列出文件

As we can see from the output that all files and folders are skipped and not copied.

从输出中可以看到,所有文件和文件夹都被跳过而不复制。

LEARN MORE  How To Install WinSCP Into Windows Operating Systems? 了解更多如何将WinSCP安装到Windows操作系统? 递归列出文件 (List Files Recursively)

While robocopy is mainly used to copy files from remote to local or local to remove we can use /L and /S options in order to list remote files. We can merge two options list and recursive to list all level files and folders.

尽管robocopy主要用于将文件从远程复制到本地或本地删除,但我们可以使用/L和/S选项列出远程文件。 我们可以合并两个选项列表和递归列表所有级别的文件和文件夹。

> robocopy mytest yourtest /L /S 复制小于给定大小的文件 (Copy Files Lower Than Given Size)

While copying files we can specify the size of files we want to copy. In this example we will copy files those sizes are lower than 1K .  We will use the /MAX option for this.

复制文件时,我们可以指定要复制的文件大小。 在此示例中,我们将复制那些大小小于1K 。 我们将使用/MAX选项。

> robocopy mytest yourtest /S /MAX:1000 Copy Files Lower Than Given Size Copy Files Lower Than Given Size 复制小于给定大小的文件

As we can see from the results some of the files are copied but some of them are not copied because of the size restriction.

从结果中我们可以看到,由于大小限制,某些文件被复制了,但有些文件没有被复制。

复制大于给定大小的文件 (Copy Files Higher Than Given Size)

The reverse of the previous option is /MIN option . This will only copy files higher than the given size. In this example, we will copy files higher than 1K which is 1000 kilobytes.

上一个选项的相反是/MIN选项。 这只会复制大于给定大小的文件。 在此示例中,我们将复制大于1K(即1000 KB)的文件。

> robocopy mytest yourtest /S /MIN:1000 Copy Files Higher Than Given Size Copy Files Higher Than Given Size 复制大于给定大小的文件 移动文件(Move Files)

The default behavior of robocopy is copying files. Sometimes we may need to move files. This can be done with robocopy too. We will provide /MOV option in order to move files and folders.

robocopy的默认行为是复制文件。 有时我们可能需要移动文件。 这也可以用robocopy完成。 我们将提供/MOV选项以移动文件和文件夹。

> robocopy mytest yourtest /S /MOVE 记录作业 (Logging Operations)

While doing copy and move operations we can also need some logs, especially in bulk data operations. We can write a log about specified operations with /LOG option. We can also specify the log file name y adding at the end of /LOG option. In this example, we will write robocopy operation log to log file named backup.log . This will prevent regular output

在执行复制和移动操作时,我们还需要一些日志,尤其是在批量数据操作中。 我们可以使用/LOG选项编写有关指定操作的/LOG 。 我们还可以指定在/LOG选项末尾添加的日志文件名y。 在此示例中,我们将robocopy操作日志写入名为backup.log日志文件。 这将阻止常规输出

> robocopy mytest yourtest /S /LOG:backup.log

The log file can be listed with type command in MS-DOS command line like below.

可以在MS-DOS命令行中使用type命令列出日志文件,如下所示。

> type backup.log Log Log 记录 复制给定的文件属性(Copy Given File Properties)

Files and folders may have different properties. These properties can be used for different purposes like the listing owner, audit information, timestamps, etc. We can copy these attributes too with the robocopy command. Here are the attributes we can specify for the copy. We will also use /copy: option by adding the property we want to copy.

文件和文件夹可能具有不同的属性。 这些属性可用于列表所有者,审核信息,时间戳等不同目的。我们也可以使用robocopy命令复制这些属性。 这是我们可以为副本指定的属性。 我们还将通过添加要复制的属性来使用/copy:选项。

D is used to copy data properties

D用于复制数据属性

A used for attributes

A用于属性

T for time stamps

T为时间戳

S is used for NTFS access control list simply ACL

S用于NTFS访问控制列表,仅用于ACL

O is used for the owner information

O用于所有者信息

U is used for Auditing information

U用于审核信息

LEARN MORE  How To Use Psexec Tools To Run Commands and Get Shell Remote Windows Systems? 了解更多信息如何使用Psexec工具运行命令并获取Shell远程Windows系统?

In this example, we will copy time stamp attributes or properties with the following command.

在此示例中,我们将使用以下命令复制时间戳记属性或属性。

> robocopy mytest yourtest /copy:T 使用/ copyall复制所有属性 (Copy All Attributes with /copyall)

We can also copy files with all properties of attributes with the /copyall parameter like below. This is equal to the /copy:DATSOU.

我们还可以使用/copyall参数复制具有属性的所有属性的文件,如下所示。 这等于/copy:DATSOU 。

> robocopy mytest yourtest /copyall 删除或删除源中不再存在的目标文件和目录 (Delete or Remove Destination Files and Directories That No Longer Exist In The Source)

If we are trying to make an identical copy of the local files and directories to the remote we need to purge or remove remote files and directories that no longer exist in the source. We can use /purge option for this.

如果我们尝试将本地文件和目录复制到远程目录,则需要清除或删除源文件中不再存在的远程文件和目录。 我们可以使用/purge选项。

> robocopy mytest yourtest /purge

翻译自: https://www.poftut.com/windows-robocopy-command-tutorial-examples-copy-files-safe-way/

robocopy复制文件



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3