看板 MaRoon
作者 標題 比較檔案/資料夾是否相同
時間 2015年03月21日 Sat. PM 02:01:24
使用FC.exe
了解ERRORLEVEL的差別:
ERRORLEVEL=2 =>表示兩個檔案中,有一個以上是不存在
ERRORLEVEL=1 =>表示比較結果為『不同』。
ERRORLEVEL=0 =>表示比較結果為『相同』。
註: 不加 >nul ,cpu會飆到100
( >nul 就是 把原本該指令要顯示在畫面上的內容,轉到空的device,也就是不顯示的意思。)
範例:
@echo off
fc c:\test.rar c:\temp\test.rar > nul
if errorlevel 2 goto err2
if errorlevel 1 goto err1
if errorlevel 0 goto err0
goto exit
:err0
echo. is same
goto exit
:err1
echo. is different
goto exit
:err2
echo. file is lost
goto exit
:exit
--
※ 作者: KTR150Fi 時間: 2015-03-21 14:01:24
※ 看板: MaRoon 文章推薦值: 0 目前人氣: 0 累積人氣: 62
回列表(←)
分享