6# hua841123 - @echo off
- setlocal disabledelayedexpansion
- title 修改中...
-
- rem 设置
- set "dir=D:\1"
- set replace_list="禁止2=允许1" "禁止5=允许5" "哈※=呵"
-
- rem 输出文件列表
- dir /s /b /a:-d-r "%dir%\*.txt" >..tmp || goto exit
-
- rem 统计文件个数
- for /f %%i in (' "find /c /v "" <..tmp" ') do (
- set /a n_total = %%i, n_current = 0
- )
-
- rem 替换
- set "s= "
- for /f "delims=" %%i in (..tmp) do (
- set /a n_current += 1
- findstr /n .* "%%i" >..tmp
- (
- for /f "delims=" %%a in (..tmp) do (
- set str=%%a
- setlocal enabledelayedexpansion
- set /p =%s: =%!n_current! / %n_total% <nul >con
- set str=!str:*:=!
- for %%a in (%replace_list%) do (
- if defined str set str=!str:%%~a!
- )
- echo,!str!
- endlocal
- )
- ) >"%%i"
- )
-
- :exit
- title 完成
- del ..tmp 2>nul
- echo,
- echo 按任意键退出...
- pause >nul
复制代码
|