标题: [文本处理] 批处理从txt中查找字符的下一行失败了 [打印本页]
作者: hentai87 时间: 2020-6-5 16:47 标题: 批处理从txt中查找字符的下一行失败了
- for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
- for /f "skip=%n% delims=" %%b in (..\set.txt) do (
- set MT=%%b\Mount\Install
- set dism=%%b\Bin\x64\DISM10\dism.exe
- )
- for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
- for /f "skip=%n% delims=" %%b in (..\set.txt) do (
- set win=%%b
- )
- echo %MT%
- echo %win%
- pause
复制代码
要显示“msmg设置”的下一行,”win版本”的下一行
从运行结果来看,都是显示的最后一行。。。。。
作者: flashercs 时间: 2020-6-5 19:54
- for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
- for /f "skip=%n% delims=" %%b in (..\set.txt) do (
- set MT=%%b\Mount\Install
- set dism=%%b\Bin\x64\DISM10\dism.exe
- goto next1
- )
- :next1
- for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
- for /f "skip=%n% delims=" %%b in (..\set.txt) do (
- set win=%%b
- goto next2
- )
- :next2
- echo %MT%
- echo %win%
- pause
复制代码
作者: 路过 时间: 2020-6-5 20:21
- for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
- (for /l %%a in (0,1,%n%) do (set /p line=))<..\set.txt
- set MT=%line%\Mount\Install
- set dism=%line%\Bin\x64\DISM10\dism.exe
- for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
- (for /l %%a in (0,1,%n%) do (set /p line=))<..\set.txt
- set win=%line%
- echo %MT%
- echo %win%
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |