xcopy : 복사 대신 파일을 이동 하시겠습니까? 이동하기 위해 xcopy에서

xcopyVerify 플래그를 사용하여 네트워크를 통해 파일을 복사하지 않고 이동하는 데 사용 하고 싶습니다 . 파일을 이동하기 위해 xcopy에서 스위치를 찾을 수 없습니다. xmove사용할 수 verify있습니까?

현재 사용하고 xcopy /D /V있지만 파일이 대상으로 성공적으로 복사되었음을 확인했을 때만 소스에서 파일을 제거해야 합니다.



답변

당신은 robocopy그것을 확인해야합니다 , 그것은 훨씬 더 강력합니다 xcopy. /MOV또는 로 파일을 쉽게 이동할 수 있습니다 /MOVE.

파일 만 이동하려면 (복사 후 소스에서 삭제)

robocopy from_folder to_folder files_to_copy /MOV

파일 및 디렉토리를 이동하려면 (복사 후 소스에서 삭제)

robocopy from_folder to_folder files_to_copy /MOVE

http://ss64.com/nt/robocopy.html


답변

배치 파일을 사용 Xcopy하여 verify로 명령 을 실행 한 다음 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.

배치 예 :

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.

답변