这样可能更精确一些,如果文件中不存在最后一个字符是2的行,则不处理:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%I in ('findstr /r /m "2$" *.txt') do (
- (for /f "delims=" %%a in ('type "%%I"') do (
- set "str=%%a"
- if "!str:~-1!"=="2" (
- for /f "tokens=1,2* delims=*" %%i in ("%%a") do set "str=%%i*01*%%k"
- )
- echo,!str!
- ))>$
- move "$" "%%I"
- )
- pause
复制代码
|