BAT Copy File

Source: Internet
Author: User

Recently, when deploying a server, you need to copy a site file to another site. A manual copy is too tiring, wrote a simple batch file, basically can achieve the purpose, specifically how to do it:

1, the need to copy the files to each site, put in a separate directory. Like E:\WebSite\orig\.

2, using the dos xcopy command, the source file orig copy to each destination file, the script is as follows:

xcopy E:\website\orig\*.* D:\WebSite\Site1\/s/f/r/y/E

xcopy E:\website\orig\*.* D:\WebSite\Site2\/s/f/r/y/E

xcopy E:\website\orig\*.* D:\WebSite\Site3\/s/f/r/y/E

3, save the above code as Copy.bat. Each time you publish, publish the file you want to copy to the E:\WebSite\orig\ directory, and then double-click the Copy.bat batch file to run it.

The detailed usage of Xcopy can be viewed in the cmd window, by entering help Xcop. On my machine, the display usage is as follows:

C:\Documents and Settings\administrator>help xcopy
Copy files and directory trees.


XCOPY source [Destination] [/a |/M] [/d[:d ate]] [/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 copies only files with the archive attribute set,
But does not change the properties.
/M copies only files with the archive attribute set,
And close the archive properties.
/d:m-d-y copies files that change after a specified date or a specified date.
If no date is provided, only those source time are copied
New files than the target time.
/EXCLUDE:FILE1[+FILE2][+FILE3] ...
Specifies a list of files that contain strings. Every single string
Must be in a separate line in the file. If there is any
The absolute path of the string and the file to be copied
Match, that file will not be copied.
For example, specifying a string such as \obj\ or. obj would exclude
All files below the directory obj or with
file with the. obj extension.
/P prompt before creating each target file.
/S Copy directories and subdirectories, except empty.
/e copies directories and subdirectories, including empty.
Same as/s/e. Can be used to modify/T.
/v validates each new file.
/w prompts you to press the key before copying.
/C Continue copying even if there is an error.
/I if the target does not exist and is copying more than one file,
It is assumed that the target must be a directory.
/q does not display the file name when copying.
/F Displays the full source and destination file names when copying.
/L Displays the files to be copied.
/g allows files that are not encrypted to be copied to
The target for encryption is not supported.
/h also copies hidden and system files.
/R overwrites read-only files.
/T Creates a directory structure, but does not copy files.
Empty directories or subdirectories are not included. /T/E includes
Empty directories and subdirectories.
/U copies only files that already exist in the target.
/k Copy Properties. General Xcopy resets the read-only attribute.
/n is copied with the generated short name.
/o copies file ownership and ACL information.
/x Copies the file audit settings (implied/O).
/y Copy file audit settings (implied/O).
The existing target file.
/-y causes a prompt to confirm overwriting a
The existing target file.
/z copies network files in restart mode.


command-line switches/y can be pre-set in the COPYCMD environment variable.
This may be overridden by the/-y on the command line.

BAT Copy File

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.