posts - 91,  comments - 2,  views - 11万
复制代码
 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
复制代码

 

posted on   le.li  阅读(4965)  评论(0编辑  收藏  举报
编辑推荐:
· 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)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示