Copy files and folders using the xcopy command for Batch Processing)

Source: Internet
Author: User

You can use xcopy, that is, xcopy obt \ *. * c: \ windows \ obt \/S/E
Xcopy also has many functions, which are completed by adding parameters. The above/S/e parameters are used to copy all subdirectories and empty directories. Some examples and parameter descriptions are as follows:
1. If you just copy all files on the E: \ disk to the D: \ disk, enter "xcopy E: \ *. * D:/S/H! If you do not want to copy files during the copy process! Press the keyboard key "Ctrl" + "Pause/Break" to interrupt replication.
2. If you want to copy all the files on the E: \ disk to the D: \ disk, copy them one by one today, copy them one by one tomorrow, and then copy them the next day. Or, for some reason, the last copy was not completed, and I want to copy it again today. (This is often the case when copying files.) What should I do?
Enter "xcopy E: \ *. * D:/S/H/D/y. He can find out that the files have been copied and those files have not been copied.
3. Of course we will also encounter this situation. We have modified some files! The latest version is available on the Internet. We need to update the original backup file in time. So how can we synchronize updates? Of course, we can copy the latest good files. This is also a solution.
If there are many modified files, you will not be able to remember that the file has been updated. So many original backup files must be updated and copied. This is not a task that saves effort and is prone to errors and some files are forgotten!
Enter "xcopy E: \ *. * D:/S/H/D/y" just like above!
4. There is also a situation that we often encounter because an error occurs when copying a file or the file is in use, and the copy operation is stopped (for example, copying Windows XP on a C drive) at this time, we want to skip an incorrect file and a file in use and continue copying other files.
Add one more parameter "/C", that is, "xcopy E: \ *. * D:/S/H/D/C/y!
5. Sometimes we want to change xcopy to automatic copy, and shut down the computer after the copy is complete, we can create a batch file, create a new text file, and rename it xcopy. of course, the extension of BAT is originally in TXT format and should be renamed to bat in this xcopy. input in bat
Xcopy E: \ *. * D:/S/H/C/y
Shutdown-S
Double-click xcopy. BAT to run it. You can go out and play now. The computer automatically copies the backup file and closes the computer.

xcopy source [destination] parameter (for example,/S/E)
source specifies the file to be copied.
destination specifies the location and/or name of the new file.
/A only Copies files with an archived property set.
the attributes are not changed.
/m only Copies files with an archive property set.
disable the archive property.
/D: M-D-Y: copy the objects that have changed since the specified date or date.
if no date is provided, only files whose source time is earlier than the target time are copied.
/exclude: file1 [+ file2] [+ file3]...
specifies the list of files containing strings. If any
string matches the absolute path of the file to be copied
, the file will not be copied.
for example, specifying strings such as \ OBJ \ or. OBJ will exclude all files under the
directory OBJ or files with the
. OBJ extension.
/P prompt before creating each target file.
/s copies directories and subdirectories, except empty.
/E: Copy directories and subdirectories, including empty ones.
same as/S/e. It can be used to modify/t.
/V verify each new file.
/W prompts you to press the button before copying.
/C continues copying even if an error occurs.
/I if the target does not exist and more than one file is being copied,
assume that the target must be a directory.
the file name is not displayed during/Q replication.
/F indicates the complete source and target file names.
/L displays the file to be copied.
/g allows copying unencrypted files to targets
encryption is not supported.
/H also copies hidden and system files.
/R rewrite the read-only file.
/t create a directory structure, but do not copy files. No
contains empty directories or subdirectories. /T/e Includes
empty directories and subdirectories.
/u only Copies files that already exist in the target.
/K copy attributes. Generally, xcopy will reset the read-only attribute.
/N is copied using the generated short name.
/O: copy the file ownership and ACL information.
/X copy file audit settings (implicit/O ).
/y forbidden prompt to confirm rewriting of An
existing target file.
/-y causes a prompt to confirm rewriting of An
existing target file.
/Z: Copy network files in restart mode.

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.