Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Description and usage of cmd copy command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "the description and use of the cmd copy command". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Copy, which means "copy" in Chinese, is a command that is easy to see the name and meaning. Its function is to copy the file, and the usage is very simple: the destination path of the copy source file.

1, command description

Copy one or more documents to another location.

COPY [/ D] [/ V] [/ N] [/ Y | /-Y] [/ Z] [/ L] [/ A | / B] source [/ A | / B]

[+ source [/ A | / B] [+...]] [destination [/ A | / B]]

Source specifies the file to copy.

/ A represents an ASCII text file.

/ B represents a binary file.

/ D allows you to decrypt the target file to be created

Destination specifies a directory and / or file name for the new file.

/ V verify that the new file is written correctly.

/ N when copying a file with a non-8dot3 name

Use short file names whenever possible.

/ Y do not use to confirm whether you want to overwrite the existing target file

A hint.

/-Y use to confirm whether you want to overwrite the existing target file

A hint.

/ Z copies networked files in rebootable mode.

/ L if the source is a symbolic link, copy the link

The actual file that the link points to instead of the source to the destination.

The command line switch / Y can be pre-set in the COPYCMD environment variable.

This may be replaced by /-Y on the command line. Unless COPY

The command is executed in a batch script and the default value should be

Prompt when overwriting.

To attach a file, specify a file for the destination and a file for the source

Several files (in wildcard or file1+file2+file3 format).

2, example

The COPY command can only copy files, not folders.

1, copy of a single file

Example 1, copy the 123.txt to the d:\ directory. If this operation is successful, the command line window prompts "1 file copied".

Copy c:\ 123.txt d:\

Example 2, copy 123.txt to the d:\ directory and change it to abc.bat, where the file name and its format are changed.

Copy c:\ 123.txt d:\ abc.bat

Example 3, copy all the files in the 123 subdirectory under the current directory to the current directory.

Copy.

2. Copy files in batch

In example 1, copy all the files in the c:\ 123 directory to the d:\ abc directory.

Copy c:\ 123d:\ abc

Example 2, copy all the files in rm format in the c:\ 123 directory to the d:\ abc directory, when the target directory already exists like the files to be copied in the source directory

When a file with the same file name appears, a prompt such as "rewrite x:\ xx? (Yes/No/All):" allows you to choose whether to overwrite, not to overwrite, or to overwrite all

Cover, through the parameter / y (can be used when copying a single file or batch copy), you can overwrite the duplicate file directly without confirmation.

Copy c:\ 123\ * .rm d:\ abc / y

3, merge files

Example 1, merge 1.mp3 and 2.mp3 into 3.mp3.

Copy / b d:\ 1.mp3 d:\ 2.mp3 e:\ 3.mp3

Example 2, merge 1.txt and 2.mp3. The combined file name is not specified here. By default, the merged file name is the first file in the command.

First name. In this case, 2.mp3 is merged into 1.txt.

Copy / b d:\ 1.txt d:\ 2.mp3

Suppose you need to copy the file d:\ test\ test.txt to the root directory of the D disk, then you can easily do it using copy d:\ test\ test.txt d:\.

Of course, this is the simplest case, in the actual use, will encounter a very complex situation.

If a file named test.txt already exists in the root directory of disk D, the copy command will prompt you whether to overwrite the original file, discard copying or overwrite all files when copying it. If you are in batch copy, all overwrite the original file, then, one by one choice is very troublesome, at this time, you can use without prompt to overwrite the original file parameter / y (equivalent to automatically selecting the Yes option), the complete command is copy / y d:\ test\ test.txt d:\.

If you also need to change the name of the source file when copying, for example, when changing test.txt to 1.txt, you can directly use the command such as copy d:\ test\ test.txt d:\ 1.txt, that is, when you specify the destination path, specify the file name directly, then the new file name is the name after the source file is copied.

If the path you want to copy contains special symbols such as spaces, &, etc., enclose these special characters in quotation marks, such as: copy "d:\ test abc\ test.txt"d:\ t&est"

In addition to the function of "copying" files, the copy command also has a unique skill: merge multiple files into one file, the specific format is: copy file 1 + file 2 + file 3 +. Destination path\ new file name. For example: copy d:\ test.txt+d:\ abc.txt d:\ test\ test.txt, then merge the contents of the test.txt and abc.txt files in the root directory of the D disk into test.txt and save them to the d:\ test directory.

Copy also has some parameters, but the most commonly used ones are the above usage. For more uses, please use copy /? in the command line window. To inquire, it's easy to get started.

It must be noted that copy can only copy files, for folder replication, you need to be smart, use xcopy to copy. Xcopy is an advanced version of copy, with richer parameters, more complex functions, and copy of all-you-can-eat files and folders, which will be introduced separately later and will not be explained here.

This is the end of the description and usage of the cmd copy command. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report