設定檢查上限後,檢查欲比對檔案大小後
如有比上限大則覆蓋原始檔。
@echo off
For /F "tokens=1-3 delims=/ " %%a IN ("%date%") Do (
Set _MyYear=%%a
set _MyMonth=%%b
set _MyDate=%%c
)
For /F "tokens=1-3 delims=: " %%a IN ("%time%") Do (
Set _MyTime=%%a%%b
)
set name=error.log
set file=%name%
for /f "tokens=4" %%s in ('dir /a-d/-c %file% ^| findstr /e %file%') do set size=%%s
set /a KB=(%size%/1024)
set /a MB=(%size%/1024)/1024
echo 檔案大小為:%KB% KB
echo 檔案大小為:%MB% MB
if /i %MB% GTR 10 (echo 該檔案大於10MB,檔案大小為:%MB% MB,執行日期:%_MyYear%,%_MyMonth%,%_MyDate%^|>>errorcoverlog.txt)
if /i %MB% GTR 10 (copy c:\error.log .\)