Pages

2012年2月28日 星期二

【CMD】批次檔檢查檔案大小

最近因為程式關係,需要檢查下傳檔案大小使否與伺服器上檔案一致,
所以需要找批次檢查檔案,因此找到一個簡易的範例。


@echo off
setlocal
set file="test.cmd"
set maxbytesize=1000

FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA

if %size% LSS %maxbytesize% (
    echo.File is ^< %maxbytesize% bytes
) ELSE (
    echo.File is ^>= %maxbytesize% bytes
)

0 意見: