我想使用xcopy验证标志通过网络移动文件,而不是复制文件。我找不到 xcopy 上的开关来移动文件,xmove我可以使用它verify吗?
目前我正在使用,xcopy /D /V但只有在验证文件已成功复制到目标时才需要删除源中的文件。
imt*_*man 11
你应该看看robocopy,它比xcopy. 您可以使用/MOV或轻松移动文件/MOVE。
仅移动文件(复制后从源中删除)
robocopy from_folder to_folder files_to_copy /MOV
Run Code Online (Sandbox Code Playgroud)
移动文件和目录(复制后从源中删除)
robocopy from_folder to_folder files_to_copy /MOVE
Run Code Online (Sandbox Code Playgroud)
http://ss64.com/nt/robocopy.html
您可以使用批处理文件来运行Xcopy带有验证的命令,然后检查 Xcopy 返回的错误级别以确定文件复制是否成功。如果他们这样做了,请删除源。
来自Xcopy 文档:
Exit
code Description
==== ===========
0 Files were copied without error.
1 No files were found to copy.
2 The user pressed CTRL+C to terminate xcopy.
4 Initialization error occurred. There is not
enough memory or disk space, or you entered
an invalid drive name or invalid syntax on
the command line.
5 Disk write error occurred.
Run Code Online (Sandbox Code Playgroud)
批次示例:
Rem Attempt file copy...
xcopy /D /V %1 %2
Rem Check result code and if it was successful (0), delete the source.
if errorlevel 0 (
echo Copy completed successfully
del /Q %1
exit /B
)
Rem Not Errorlevel 0...
echo Copy failed for some reason.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
89816 次 |
| 最近记录: |