In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to copy Xcopy files and directories, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Xcopy
Copy files and directories, including subdirectories.
Grammar
Xcopy Source [Destination] [/ w] [/ c] [/ v] [/ Q] [/ f] [/ l] [/ g] [/ d [: mm-dd-yyyy]] [/ u] [/ I] [/ s [/ e]] [/ t] [/ k] [/ r] [/ h] [{/ a | / m}] [/ n] [/ o] [/ x ] [/ exclude:file1 [+ [file2]] [+ [file3]] [{/ y | /-y}] [/ z]
Parameters.
Source
Necessary. Specify the location and name of the file to copy. The parameter must contain a drive or path.
Destination
Specify the destination of the file to copy. This parameter can contain drive letters and colons, directory names, file names, or a combination of them.
/ w
The following message appears and waits for your response before starting to copy the file:
Press any key to begin copying file (s)
/ p
Prompts you to confirm that you want to create each target file.
/ c
Ignore the error.
/ v
Verify each file when writing to the target file to ensure that the target file is exactly the same as the source file.
/ q
Suppresses the display of xcopy messages.
/ f
The source and destination file names are displayed when copying.
/ l
Displays a list of files to copy.
/ g
Create a decrypted target file.
/ d [: mm-dd-yyyy]
Copy only those source files that have changed on or after the specified date. If you do not include the mm-dd-yyyy value, xcopy copies all Source files that are newer than existing Destination files. This command line option allows you to update changed files.
/ u
Only files that are already in destination are copied from source.
/ i
If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes that destination specifies a directory name and creates a new directory. Xcopy then copies all the specified files to the new directory. By default, xcopy prompts you to specify whether destination is a file or a directory.
/ s
Copy non-empty directories and subdirectories. If / sforce xcopy is omitted, it will work in a directory.
/ e
Copy all subdirectories, including empty directories. Use both the / e, / s, and / t command line options.
/ t
Only the subdirectory structure (that is, the directory tree) is copied, not files. To copy an empty directory, you must include the / e command line option.
/ k
Copy the file, which is retained in the destination file if the source file has a read-only attribute. By default, xcopy deletes the read-only attribute.
/ r
Copy a read-only file.
/ h
Copy files with hidden and system file attributes. By default, xcopy does not copy hidden or system files.
/ a
Copy only those source files that have archive file property settings. / a does not modify the archive file properties of the source file. For information about how to set the properties of an archive file by using attrib, see.
/ m
Copy the source file with archive file property settings. Unlike / a, / m turns off the archive file properties of the files specified in the source. For information about how to set the properties of an archive file by using attrib, see.
/ n
Create a copy using a NTFS short file or directory name. / n is required to copy a file or directory from a NTFS volume to a FAT volume or when the destination file system requires an FAT file system naming convention (that is, 8.3 characters). The destination file system can be FAT or NTFS.
/ o
Copy file ownership and freely selected access control list (DACL) information.
/ x
Copy file audit settings and system access control list (SACL) information (including / o).
/ exclude:filename1 [+ [filename2]] [+ [filename3]]
Specifies a list of files that contain strings.
/ y
Do not prompt you to confirm that you want to overwrite the existing target file.
/-y
Prompts you to confirm that you want to overwrite the existing target file.
/ z
Replicate over the network in restartable mode.
/?
Displays help at the command prompt.
Annotation
Use / v
XOX
Use / exclude
Lists each string in a separate line of each file. If any string listed matches any part of the absolute path of the file to be copied, the file is excluded from the replication process. For example, if you specify the string "\ Obj\", all files in the Obj directory are excluded. If you specify the string ".obj", all files with an .obj extension are excluded.
Use / z
If a connection is lost during replication (for example, if the server used for the connection is offline), the replication process resumes after the connection is re-established. / z also shows the percentage of copy operations completed by each file.
Use / y in the COPYCMD environment variable
You can use / y in the COPYCMD environment variable. Use /-y on the command line to override the command. By default, you are prompted to override unless you run copy from within a batch script.
Copy encrypted files
Copying encrypted files to a volume that does not support EFS results in an error. You should first decrypt the file or copy the file to a volume that supports EFS.
Ancillary document
To attach a file, specify a single destination file, multiple source files (using wildcards or file 1 + file 2 + file 3 format).
Default value for Destination
If you omit the Destination,xcopy command, copy the file to the current directory.
Specify whether Destination is a file or a directory
If the Destination does not contain an existing directory and does not end with a backslash (\), the following message appears:
Does destination specify a file name
Or directory name on the target
(F = file, D = directory)?
If you want to copy one or more files to a file, press F. If you want to copy one or more files to a directory, press D.
Using the / I command line option suppresses the display of the message, causing xcopy to determine that the destination is a directory if the source is multiple files or a directory.
Use the xcopy command to set the archive properties of a Destination file
The xcopy command creates a file with archive property settings, regardless of whether this property is set in the source file or not. For more information about file properties and attrib, see ".
Compare xcopy and diskcopy
If the subdirectory of the disk contains files, to copy them to a disk with a different format, use the xcopy command instead of diskcopy. Because the diskcopy command copies disks track by track, the format of the source and destination disks must be the same. The xcopy command does not have this requirement. Usually use xcopy unless you need a complete copy of the disk image.
Exit code of xcopy
To handle the exit code returned by xcopy, use the errorlevel parameter on the if command line of the batch program. For an example of a batch program that uses if to process exit codes, see. The following table lists each exit code and description.
Exit code description
There is no error in copying the 0 file.
1 the file to be copied was not found.
2 the user terminated the xcopy by pressing CTRL+C.
4 an initialization error occurred. There is not enough memory or disk space, or an invalid drive name or syntax was entered on the command line.
5 A disk write error occurred.
Example
To copy all files and subdirectories (including all empty subdirectories) from drive A to drive B, type:
The code is as follows:
Xcopy a: b: / s / e
To include any of the systems or hidden files in the previous example, add the / h command line option as follows:
The code is as follows:
Xcopy a: b: / s / e / h
To update the files in the\ Rawdata directory with files that have changed since December 29, 1993, type:
Xcopy\ rawdata\ reports / dvl 12-29-1993
To update all files that exist in\ Reports in the example above, regardless of the date, type:
Xcopy\ rawdata\ reports / u
If you only want to get a list of files to be copied by the previous command, but not the files, type:
Xcopy\ rawdata\ reports / dvl 12-29-1993 / l > xcopy.out
The file Xcopy.out lists all the files to be copied.
To copy the\ Customer directory and all subdirectories to the directory\\ Public\ Address on network drive H:, leave the read-only attribute, and prompt you when you create a new file on H:, type:
Xcopy\ customer h:\ public\ address / s / e / k / p
To issue the previous command to ensure that xcopy creates the\ Address directory when it does not exist, and to suppress the message to be displayed when creating a new directory, add the / I command line option as follows:
Xcopy\ customer h:\ public\ address / s / e / k / p / I
You can create a batch program to perform xcopy operations and use the if batch command to process the exit code when an error occurs. For example, the following batch program uses replaceable xcopy source and destination parameters:
The code is as follows:
@ echo off
Rem COPYIT.BAT transfers all files in all subdirectories of
Rem the source drive or directory (1) to the destination
Rem drive or directory (2)
Xcopy 1 2 / s / e
If errorlevel 4 goto lowmemory
If errorlevel 2 goto abort
If errorlevel 0 goto exit
: lowmemory
Echo Insufficient memory to copy files or
Echo invalid drive or command-line syntax.
Goto exit
: abort
Echo You pressed CTRL+C to end the copy operation.
Goto exit
: exit
To use the batch program to copy all files in the C:\ Prgmcode directory and its subdirectories to drive B, type:
Copyit c:\ prgmcode b:
The command interpreter will replace% 1 and B: with C:\ Prgmcode. For% 2, then use the xcopy with / e and / s command line options. If xcopy encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate IF ERRORLEVEL statement, then displays the appropriate message and exits the batch program.
The solution to how to cancel whether the message is a directory or a file in xcopy
Xcopy d:\ testcopy\ *. * e:\ testCopy
Destination E:\ testCopy is the file name
Or the name of the directory?
(F = file, D = directory)?
How to cancel the prompt box whether this is a file or a directory?
/ Y is to override the cancellation prompt to prevent subsequent prompts
\ is to cancel the prompt when creating a new one.
Help documentation is available at XCOPY /? find
The right thing is
XCOPY D:\ dir F:\ dir\ / Y
Add\ and / Y to the new directory so that you won't be prompted multiple times for the first time.
Or we can use pipe symbols.
Echo f | XCOPY D:\ dir F:\ dir / Y
Or
Echo d | XCOPY D:\ dir F:\ dir / Y
So you don't have to bring it.
The above is all the contents of the article "how to copy files and directories in Xcopy". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.