XCOPY : Copies files and directories, including subdirectories
cmd
- xcopy /?
XOPY/复制文件和目录树。
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B] [/J]
[/EXCLUDE:file1[+file2][+file3]...]
source Required. Specifies the location and names of the files you want to copy. This parameter must include either a drive or a path./指定要复制的文件。
destination Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these./指定新文件的位置和/或名称。
/A Copies only Source files that have their archive file attributes set. /a does not modify the archive file attribute of the source file./仅复制有存档属性集的文件,但不更改属性。
/M Copies Source files that have their archive file attributes set. Unlike /a, /m turns off archive file attributes in the files that are specified in the source./仅复制有存档属性集的文件,并关闭存档属性。
/D:m-d-y Copies source files changed on or after the specified date only. If you do not include a MM-DD-YYYY value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed./复制在指定日期或指定日期以后更改的文件。如果没有提供日期,只复制那些源时间比目标时间新的文件。
/EXCLUDE:file1[+file2][+file3]... Specifies a list of files. At least one file must be specified. Each file will contain search strings with each string on a separate line in the file.When any of the strings match any part of the absolute path of the file to be copied, that file will be excuded from being copied. For example, specifying the string obj will exclude all files underneath the directory obj or all files with the .obj extension./指定含有字符串的文件列表。每个字符串在文件中应位于单独的一行。如果任何字符串与复制文件的绝对路径的任何部分相符,则排除复制该文件。例如,指定如 \obj\ 或 .obj 的字符串会分别排除目录 obj 下面的所有文件或带有.obj 扩展名的所有文件。
/P Prompts you to confirm whether you want to create each destination file./创建每个目标文件之前提示你。
/S Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory./复制目录和子目录,不包括空目录。
/E Copies all subdirectories, even if they are empty. Use /e with the /s and /t command-line options./复制目录和子目录,包括空目录。与 /S /E 相同。可以用来修改 /T。
/V Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files./验证每个新文件的大小。
/W Displays the following message and waits for your response before starting to copy files:Press any key to begin copying file(s)/提示你在复制前按键。
/C Ignores errors./即使有错误,也继续复制。
/I If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory./如果目标不存在,且要复制多个文件,则假定目标必须是目录。
/Q Suppresses the display of xcopy messages./复制时不显示文件名。
/F Displays source and destination file names while copying./复制时显示完整的源文件名和目标文件名。
/L Displays a list of files that are to be copied./显示要复制的文件。
/G Creates decrypted Destination files when the destination does not support encryption./允许将加密文件复制到不支持加密的目标。
/H Copies files with hidden and system file attributes. By default, xcopy does not copy hidden or system files/也复制隐藏文件和系统文件。
/R Copies read-only files./覆盖只读文件。
/T Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the /e command-line option./创建目录结构,但不复制文件。不包括空目录或子目录。/T /E 包括空目录和子目录。
/U Copies files from Source that exist on Destination only./只复制已经存在于目标中的文件。
/K Copies files and retains the read-only attribute on Destination files if present on the Source files. By default, xcopy removes the read-only attribute./复制属性。一般的 Xcopy 会重置只读属性。
/N Creates copies by using the NTFS short file or directory names. /n is required when you copy files or directories from an NTFS volume to a FAT volume or when the FAT file system naming convention (that is, 8.3 characters) is required on the Destination file system. The Destination file system can be FAT or NTFS./用生成的短名称复制。
/O Copies file ownership and discretionary access control list (DACL) information./复制文件所有权和 ACL 信息。
/X Copies file audit settings and system access control list (SACL) information (implies /o)./复制文件审核设置(隐含 /O)。
/Y Suppresses prompting to confirm that you want to overwrite an existing destination file./取消提示以确认要覆盖现有目标文件。
/-Y Prompts to confirm that you want to overwrite an existing destination file./要提示以确认要覆盖
现有目标文件。
/Z Copies over a network in restartable mode./在可重新启动模式下复制网络文件。
/B Copies the symbolic link instead of the files. This parameter was introduced in Windows Vista®./复制符号链接本身与链接目标。
/J Copies files without buffering. Recommended for very large files. This parameter was added in Windows Server 2008 R2./复制时不使用缓冲的 I/O。推荐复制大文件时使用。
/? Displays help at the command prompt./在命令提示符中显示帮助
Demo
- copy directories
XCOPY D:\workspace\Demo D:\publish\Demo /E /Y /C /D
- copy file
XCOPY D:\config\Demo\demo.config D:\publish\Demo\demo.config /Y