回复 17# conan52 写入日志到文件- @echo off
- REM logFile
- set "logFile=%~dp0logDT.txt"
- REM write
- echo.%date:~0,10%,%time:~0,8%>>"%logFile%"
- REM max line
- set "maxLine=20"
- REM current line num
- for /f "tokens=3 delims=:" %%i in ('find /n /c "," "%~dp0\logDT.txt"') do set "curLine=%%i"
- REM compare
- set /a "key=%curLine%-%maxLine%"
- if %key% gtr 0 (
- more +%key% "%logFile%" >"%~dp0tmp.txt"
- move /y "%~dp0tmp.txt" "%logFile%" >nul 2>nul
- )
复制代码
|