因工作需要,需要对硬盘通电时间,通电次数,总写入量和总读取量信息进行自动提取拦截。
因此特写如下代码,仅做笔记存稿和分享:
代码一:
@echo off
setlocal enabledelayedexpansion
if exist YPerror.ini (del YPerror.ini)
(for /f "tokens=* delims=, " %%a in ('dir/a/s/b .\Smart\*.ini') do (
set "p=%%~dpa" & for %%i in ("!p:~0,-1!") do (
for /f "tokens=2 delims==&" %%b in ('type "%%a" ^|findstr "PowerOnHours="^|more +1') do (if %%b GEQ 150 (echo %%~nxi 通电时间超时^(标准150小时^):%%b 小时 >>.\YPerror.ini))
for /f "tokens=2 delims=^=" %%b in ('type "%%a" ^|find "PowerOnCount="^|more +1') do (if %%b GEQ 100 (echo %%~nxi 通电次数超标^(标准100次^):%%b 次 >>.\YPerror.ini))
for /f "tokens=2 delims=^=" %%b in ('type "%%a" ^|find "HostWrites="^|more +1') do (if %%b GEQ 500 (echo %%~nxi 主机写入量总计超标^(标准500GB^):%%b GB >>.\YPerror.ini))
for /f "tokens=2 delims=^=" %%b in ('type "%%a" ^|find "HostReads="^

这段博客分享了如何使用批处理脚本自动提取硬盘的SMART信息,包括通电时间、通电次数、主机写入量和主机读取量,并对超出标准的数据进行记录。脚本适用于检测硬盘健康状况,防止数据丢失。
最低0.47元/天 解锁文章
9879

被折叠的 条评论
为什么被折叠?



