Use the xcopy command to copy local files to a remote server

Source: Internet
Author: User

A.net use \ IP address password/user :******
B. xcopy file \ IP address \
The batch file is backup. bat and the code is as follows:
========================================================== ========================================================== ==========
Net use \ 192.168.1.198 \ ipc $ z1_198703/user: fig
Xcopy g: \ backup \ *. * \ 192.168.1.198 \ data backup/D/E/Y/H/K
Net use \ 192.168.1.198 \ ipc $/delete
The Xcopy command can be used
Xcopy Source Path target path
Copy files and directories, including subdirectories.

Syntax
Xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d [: mm-dd-yyyy] [/u] [/I] [/s [/e] [/t] [/k] [/r] [/h] [{/a |/m}] [/n] [/o] [/x] [/exclude: file1 [+ [file2] [+ [file3] [{/y |/-y}] [/z]

Parameters
Source
Required. Specifies the location and name of the file to be copied. This parameter must contain the drive or path.
Destination
Specifies the target of the file to be copied. This parameter can contain drive letters, colons, directory names, file names, or combinations of them.
/W
The following message is displayed before you start copying a file and waits for your response:
Press any key to begin copying file (s)
/P
You are prompted to confirm whether to create each target file.
/C
Ignore errors.
/V
Verify each file when writing the target file to ensure that the target file is exactly the same as the source file.
/Q
Disable xcopy message display.
/F
The source file name and target file name are displayed during copy.
/L
Displays the list of files to be copied.
/G
Create the target file for decryption.
/D [: mm-dd-yyyy]
Only the source files changed after the specified date or date are copied. If the value of mm-dd-yyyy is not included, xcopy copies all the new Source files than the existing Destination files. This command line option allows you to update changed files.
/U
Only copies existing files in destination from source.
/I
If Source is a directory or contains wildcards, but Destination does not exist, xcopy assumes that destination specifies the directory name and creates a new directory. Then, xcopy copies all specified files to the new directory. By default, xcopy will prompt you to specify whether the destination is a file or a directory.
/S
Copy non-empty directories and subdirectories. If/s is omitted, xcopy will work in a directory.
/E
Copy all subdirectories, including empty directories. Use the/e,/s, and/t command line options at the same time.
/T
Only copy the sub-directory structure (that is, the directory tree) without copying files. To copy an empty directory, the/e command line option must be included.
/K
Copy a file. If the source file has a read-only attribute, this attribute is retained in the target file. By default, xcopy deletes the read-only attribute.
/R
Copy a read-only file.
/H
Copy a file that has hidden and system file attributes. By default, xcopy does not copy hidden or system files.
/
Copy only the source files with the archive file attribute settings. /A does not modify the attributes of the archive file of the source file. For information about how to use attrib to set attributes of an archive file, see "related topics ".
/M
Copy the source file with the archive file attribute settings. Unlike/a,/m disables the attributes of the specified file in the source. For information about how to use attrib to set attributes of an archive file, see "related topics ".
/N
Use the NTFS short file or directory name to create a copy. To copy a file or directory from the NTFS Volume to the FAT volume, or when the target file system requires the FAT file system Naming Convention (that is, 8.3 characters),/n is required. the target file system can be FAT or NTFS.
/O
Copy the File Ownership and the freely selected Access Control List (DACL) information.
/X
Copy File Audit settings and system access control list (SACL) information (including/o ).
/Exclude: filename1 [+ [filename2] [+ [filename3]
List of objects containing strings.
/Y
Do not prompt you to overwrite the existing target file.
/-Y
You are prompted to confirm that you want to overwrite the existing target file.
/Z
Network replication is enabled in rebootable mode.
/?
Display help at the command prompt.
Note
Use/v
Windows XP does not use this command. Use it just for compatibility with MS-DOS files. Use/exclude
Lists each string in a separate row of each file. If any string listed matches any part of the absolute path of the file to be copied, the file will be excluded from the copy process. For example, if the string "\ Obj \" is specified, all files in the Obj directory are excluded. If the string ". obj" is specified, all files with the. obj extension are excluded.
Use/z
If the connection is lost during the replication process (for example, if the server used for connection is offline), the replication process will be restored after the connection is established again. /Z also displays the percentage of copies completed for each file.
Use/y in COPYCMD Environment Variables
You can use/y in the COPYCMD environment variable. Use/-y on the command line to overwrite the command. By default, you will be prompted to overwrite, unless you run copy from the batch processing script.

Copy Encrypted Files
Copying an encrypted file to a volume that does not support EFS may cause an error. Files should be decrypted or copied to EFS-supported volumes first.

Ancillary documents
To attach a file, specify a single target file and multiple source files (using wildcards or file 1 + file 2 + file 3 Format ).

Default Value of Destination
If Destination is omitted, the xcopy Command copies the file to the current directory.
Specify whether Destination is a file or a directory
If Destination does not contain an existing Directory and does not end with a backslash (\), the following message is displayed:
Does destination specify a file name
Or directory name on the target
(F = file, D = directory )?
If you want to copy one or more files to one file, press F. If you want to copy one or more files to one directory, press D.
You can use the/I command line option to suppress the display of the message, so that xcopy determines that the target is a directory when the source is multiple files or one directory.
Use the xcopy command to set the archiving attribute of the Destination file
The xcopy command creates a file with the archive attribute settings, regardless of whether this attribute is set in the source file. For more information about file attributes and attrib, see related topics ".

Compare xcopy and diskcopy
If the subdirectory of the disk contains files and you want to copy them to a disk of different formats, use the xcopy command instead of diskcopy. because the diskcopy Command copies a disk from a track to a track, the format of the source disk and the target disk must be the same. The xcopy command does not have this requirement. In general, use xcopy unless you need a complete copy of the disk image.

Exit code of xcopy
To process the exit code returned by xcopy, use the errorlevel parameter on the if command line of the batch processing program. For examples of batch processing programs that use "if" to process exit codes, see "related topics". The following table lists each exit code and description.

Exit Code Description
There is no error in copying 0 files.
1. the file to be copied is not found.
2. The xcopy is terminated by pressing CTRL + C.
4. An initialization error occurs. There is not enough memory or disk space, or an invalid drive name or syntax is entered on the command line.
5. disk write error
The above is how xcopy copies local files to a remote server.

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.