1 @echo off 2 rem CMD:"color --help" 3 :: setting color:back white,content blue 4 color f9 5 6 ::old string and replace string 7 set old_str=ip 8 set new_str=#ip 9 10 :FILE 11 set "souerce_path=D:\xxx\bat\my_test.txt" 12 for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%souerce_path%"') do ( 13 set "lineContent=%%j" 14 ::echo ==%%j== 15 setlocal EnableDelayedExpansion 16 if not "!lineContent!"=="" set "lineContent=!lineContent:%old_str%=%new_str%!" 17 >>"temp.txt" echo.!lineContent! 18 endlocal 19 ) 20 move /y temp.txt "%souerce_path%" 21 goto END 22 23 :PATH 24 ::files path 25 set "souerce_path=D:/xxx/bat" 26 cd /d "%souerce_path%" 27 28 :: dir /s /b /a-d *.txt ::get all current and sub path file name with post .txt 29 for /f "delims=" %%a in ('dir /s /b /a-d *.txt') do ( 30 for /f "tokens=1* delims=:" %%i in ('findstr /n .* "%%a"') do ( 31 set "lineContent=%%j" 32 ::echo ==%%j== 33 ::here use "setlocal EnableDelayedExpansion" to keep content "!" 34 setlocal EnableDelayedExpansion 35 if not "!lineContent!"=="" set "lineContent=!lineContent:%old_str%=%new_str%!" 36 >>"%%~dpnxas" echo.!lineContent! 37 endlocal 38 ) 39 del /s /q /f "%%a" >nul 40 ren *.txts *.txt 41 ) 42 :END 43 echo ---------ok---------- 44 pause>nul
le.li
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)