Batch Processing (copying folders and files) commands

Source: Internet
Author: User

A batch processing is used:

Xcopy "C: \ Users \ portal-admin \ Desktop \ systemwithin \ index_h1_002_hscn.jpg" "C: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 14 \ template \ images \"

 

Xcopy \ path of the copied file \/Add parameters/parameters.

The parameters are as follows:

Copy the file and directory tree.
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]
[/Exclude: file1 [+ file2] [+ file3]...]
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,
But does not change attributes.
/M only Copies files with an archive property set,
Disable the archive attribute.
/D: M-D-Y: copy the objects that have been changed since the specified date or date.
If no date is provided, only the source time is copied.
A file that is newer than the target time.
/Exclude: file1 [+ file2] [+ file3]...
List of objects containing strings. Each string
It must be in a separate row of the file. If any
Absolute path of the string and the file to be copied
The file will not be copied.
For example, strings such as \ OBJ \ or. OBJ are excluded.
All files under the OBJ directory or
File 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, copy more than one file,
It is assumed 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
Encryption targets are not supported.
/H also copies hidden and system files.
/R overwrites the read-only file.
/T create directory structure, but do not copy files.
Does not include 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 resets the read-only attribute.
/N is copied with the generated short name.
/O copy the file ownership and ACL information.
/X copy file audit settings (implicit/O ).
/Y copy file audit settings (implicit/O ).
Existing target file.
/-Y causes a prompt to confirm rewriting of
Existing target file.

For example, if you copy D: \ game qq to E: \ game and all the folders include subfolders, the command is as follows:

Echo off

Xcopy D: \ GAME \ qq e: \ GAME \/E

Exit

When you copy a folder using the xcopy command, the following prompt always appears:
Target E: \ GAME \ is the file name
Or directory name
(F = file, D = directory )?

Solution: Add \ In the copied path!

Remember to copy the path, not the copied path!

 

Using xcopy to copy folders without copying subfolders means to copy the corresponding format to a folder. For example, to copy all DLL files in c: \ 1 to d \ 2, the 1 \ folder has many sub-folders. During the replication process, the sub-folders are not copied, but the corresponding DLL files are copied.


Xcopy cannot only copy files but not folders

The following code can be implemented:
For/F "tokens = *" % I in ('dir/B/S C: \ *. dll ') Do (
Copy "% ~ I "" D: \ 2 \ % ~ Nxi"
)

From: http://blog.163.com/ningbao911@126/blog/static/3743053820127741247307/

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.