A summary of the differences between copy and XCOPY commands in batch processing _dos/bat

Source: Internet
Author: User

The difference between copy and Xcopy

One, copy cannot rename this file name while copying files in files that have subdirectories

Description, here C: for the root directory, Bat is a subdirectory, and Xcopy can, but will be prompted, of course, can add parameters without prompting it.

Copy Code code as follows:

C:\>copy C:\bat\hai.bat D:\bat\hello.bat

Hint: The system cannot find the specified path.
0 files have been copied.

You can do this:

Copy Code code as follows:

C:\>copy C:\hai.bat D:\hell.bat
1 files have been copied

C:\>xcopy C:\bat\hai.bat D:\bat\hello.bat
Target D:\bat\hello.bat is the filename
or a directory name
(F = file, D = directory)? F
C:\bat\hai.bat
1 files were copied

Two, the copy command can merge two files, and Xcopy cannot

Merge files 1.txt and 2.txt into 3.txt

Copy Code code as follows:

copy/b C:\1.txt+2.txt C:\3.txt

Command format: copy/b file 1+ file ... File n merged file name
Command Tutorial: Use "+" to combine multiple files of the same or different format into one file.

Small tip:

1, a picture file that hides text data at the tail end, the hidden text data may be lost when the other file editor is used and saved.
2,mp3 files can be continuously played after they are connected by using this method.
3, synthetic Pictures/songs such binary files must use the/b parameter (binaty, binary), or it will fail;
The other merge parameter is/A (ASCII, text file) and can only be used for consolidation of plain text.
Two parameters cannot be used at the same time, binary can combine text files and binaries, and text is used for pure text merging.

Three, c:\>copy C:\bat\hai D:\hello

Command explanation: Copy all files in the C-disk bat directory to the Hello directory in D disk. If you want to select a specified type of file (such as TXT file) to D:\hello, you can use:

Copy Code code as follows:

C:\>copy C:\bat\hai\*.txt D:\hello

Note: Files and folders under subdirectories are not replicated. d Disk Hello directory must exist

Copy Code code as follows:

C:\>xcopy C:\bat\hai d:\hello/e/h

Command explanation:
Copy the C disk bat folder into the D disk Hello folder, including all subdirectories and files with hidden and system file attributes. Whether or not the Hello folder already exists, the system prompts you to create it if it does not exist.

Description
/e indicates that all subdirectories are replicated, including empty directories. /h copy files that have hidden and system file attributes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.