使用robocopy复制传递文件
robocopy语法:
robocopy <source> <destination> [<file>[ ...]] [<options>]
| Option | Description |
|---|---|
| /s | Copies subdirectories. This option automatically excludes empty directories. |
| /e | Copies subdirectories. This option automatically includes empty directories. |
| /lev: |
Copies only the top n levels of the source directory tree. |
| /z | Copies files in restartable mode. In restartable mode, should a file copy be interrupted, robocopy can pick up where it left off rather than recopying the entire file |
| /b | Copies files in backup mode. In backup mode, robocopy overrides file and folder permission settings (ACLs), which might otherwise block access. |
| /zb | Copies files in restartable mode. If file access is denied, switches to backup mode. |
| /j | Copies using unbuffered I/O (recommended for large files). |
| /efsraw | Copies all encrypted files in EFS RAW mode. |
| /copy: |
Specifies which file properties to copy. The valid values for this option are: D - DataA - Attributes T - Time stamps X - Skip alt data streams S - NTFS access control list (ACL) O - Owner information U - Auditing information The default value for the /COPY option is DAT (data, attributes, and time stamps). The X flag is ignored if either /B or /ZB is used. |
| /dcopy: |
Specifies what to copy in directories. The valid values for this option are: D - Data A - Attributes T - Time stamps E - Extended attribute X - Skip alt data streams The default value for this option is DA (data and attributes). |
| /sec | Copies files with security (equivalent to /copy:DATS). |
| /copyall | Copies all file information (equivalent to /copy:DATSOU). |
| /nocopy | Copies no file information (useful with /purge). |
| /secfix | Fixes file security on all files, even skipped ones. |
| /timfix | Fixes file times on all files, even skipped ones. |
| /purge | Deletes destination files and directories that no longer exist in the source. Using this option with the /e option and a destination directory, allows the destination directory security settings to not be overwritten. |
| /mir | Mirrors a directory tree (equivalent to /e plus /purge). Using this option with the /e option and a destination directory, overwrites the destination directory security settings. |
| /mov | Moves files, and deletes them from the source after they're copied. |
| /move | Moves files and directories, and deletes them from the source after they're copied. |
| /a+:[RASHCNET] | Adds the specified attributes to copied files. The valid values for this option are: R - Read only A - Archive S - System H - Hidden C - Compressed N - Not content indexed E - Encrypted T - Temporary |
| /a-:[RASHCNETO] | Removes the specified attributes from copied files. The valid values for this option are: R - Read only A - Archive S - System H - Hidden C - Compressed N - Not content indexed E - Encrypted T - Temporary O - Offline |
| /create | Creates a directory tree and zero-length files only. |
| /fat | Creates destination files by using 8.3 character-length FAT file names only. |
| /256 | Turns off support for paths longer than 256 characters. |
| /mon: |
Monitors the source and runs again when more than n changes are detected. |
| /mot: |
Monitors the source and runs again in m minutes if changes are detected. |
| /rh:hhmm-hhmm | Specifies run times when new copies can be started. |
| /pf | Checks run times on a per-file (not per-pass) basis. |
| /ipg: |
Specifies the inter-packet gap to free bandwidth on slow lines. |
| /sj | Copies junctions (soft-links) to the destination path instead of link targets. |
| /sl | Don't follow symbolic links and instead create a copy of the link. |
| /mt: |
Creates multi-threaded copies with n threads. n must be an integer between 1 and 128. The default value for n is 8. For better performance, redirect your output using /log option. The /mt parameter can't be used with the /ipg and /efsraw parameters. |
| /nodcopy | Copies no directory info (the default /dcopy:DA is done). |
| /nooffload | Copies files without using the Windows Copy Offload mechanism. |
| /compress | Requests network compression during file transfer, if applicable. |
| /sparse | Enables retaining the sparse state of files during copy. |
net use语法:
net use \\ip "密码" /user:用户名
net use * delete #删除已有连接,避免出现一个用户使用多重连接
举例说明:我们需要在服务器上运行脚本,将某个文件夹里的所有文件发送给局域网内所有客户机。
START 172.16.163.238.bat
rem 172.16.163.238.bat
set SERVER_PATH=\\172.16.164.32\d$\SharedDocs
set CLIENT_PATH=\SharedDoc\
set CLIENT_NAME=\\172.16.163.238
net use %CLIENT_NAME%\%CLIENT_PATH% "P@ssw0rd" /user:administrator
robocopy %SERVER_PATH% %CLIENT_NAME%\%CLIENT_PATH% *.doc
exit
浙公网安备 33010602011771号