|
|
本帖最后由 aloha20200628 于 2026-3-15 19:26 编辑
再给两个纯批版本如下...
一。不用 findstr 定位两个目标行
- @echo off &setlocal &set "inF=appxmanifest.xml" &set "outF=appxmanifest.NEW.xml"
- (for /f "usebackq delims=" %%s in ("%inF%") do (
- set "s=%%s" &setlocal enabledelayedexpansion
- if "!s!" neq "!s:*ms-resource:WebExperienceHostDescription=!" (echo,!s:~,-1! AppListEntry="none"^>) else if "!s!" neq "!s:*WindowsBackup\Assets\AppList.png=!" (echo,!s:~,-1! AppListEntry="none"^>) else echo,!s!
- endlocal ))>"%outF%"
- pause&exit/b
复制代码
二。先采用 findstr 定位两个目标行
- @echo off &setlocal &set "inF=a.xml" &set "outF=a.new.xml"
- for /f "delims=:" %%a in ('findstr /iln "ms-resource:WebExperienceHostDescription WindowsBackup\Assets\AppList.png" "%inF%" ') do if defined n1 (set "n2=%%a") else set "n1=%%a"
- (for /f "tokens=1* delims=:" %%a in ('findstr /n ".*" "%inF%" ') do (
- set "s=%%b" &setlocal enabledelayedexpansion
- if %%a equ %n1% (echo,!s:~,-1! AppListEntry="none"^>) else if %%a equ %n2% (echo,!s:~,-1! AppListEntry="none"^>) else echo,!s!
- endlocal ))>"%outF%"
- pause&exit/b
复制代码
|
评分
-
查看全部评分
|