本帖最后由 77七 于 2023-1-27 22:52 编辑
- @echo off
- cd /d "%~dp0"
- set /p str=请输入固定文字:
- for /f "delims=" %%i in ('dir /b /a-d *.txt') do (
- for /f "delims=" %%m in ('type "%%~nxi"') do (
- set "line=%%m"
- setlocal enabledelayedexpansion
- set "line=!line:<time>=@!"
- set "line=!line:</time>=@!"
- for /f "tokens=1-3 delims=@" %%a in ("#!line!#") do (
- if "%%b" equ "" (
- echo !line!
- ) else (
- set "line2=%%a<time>%str%</time>%%c"
- echo !line2:#=!
- )
- )
- endlocal
- )>>xxx.temp
- move /y xxx.temp "%%~nxi"
- )
- pause
复制代码
我水平太差,只能写成这样,试试能行吗?如果原文本里有@#这个符号,可以把@#换成生僻汉字
使用前先测试或备份 |