Board logo

标题: [文本处理] 批处理从txt中查找字符的下一行失败了 [打印本页]

作者: hentai87    时间: 2020-6-5 16:47     标题: 批处理从txt中查找字符的下一行失败了

  1. for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
  2. for /f "skip=%n% delims=" %%b in (..\set.txt) do (
  3. set MT=%%b\Mount\Install
  4. set dism=%%b\Bin\x64\DISM10\dism.exe
  5. )
  6. for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
  7. for /f "skip=%n% delims=" %%b in (..\set.txt) do (
  8. set win=%%b
  9. )
  10. echo %MT%
  11. echo %win%
  12. pause
复制代码
要显示“msmg设置”的下一行,”win版本”的下一行
从运行结果来看,都是显示的最后一行。。。。。
作者: flashercs    时间: 2020-6-5 19:54

  1. for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
  2. for /f "skip=%n% delims=" %%b in (..\set.txt) do (
  3. set MT=%%b\Mount\Install
  4. set dism=%%b\Bin\x64\DISM10\dism.exe
  5. goto next1
  6. )
  7. :next1
  8. for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
  9. for /f "skip=%n% delims=" %%b in (..\set.txt) do (
  10. set win=%%b
  11. goto next2
  12. )
  13. :next2
  14. echo %MT%
  15. echo %win%
  16. pause
复制代码

作者: 路过    时间: 2020-6-5 20:21

  1. for /f "delims=:" %%a in ('findstr /n msmg设置 ..\set.txt') do set n=%%a
  2. (for /l %%a in (0,1,%n%) do (set /p line=))<..\set.txt
  3. set MT=%line%\Mount\Install
  4. set dism=%line%\Bin\x64\DISM10\dism.exe
  5. for /f "delims=:" %%a in ('findstr /n win版本 ..\set.txt') do set n=%%a
  6. (for /l %%a in (0,1,%n%) do (set /p line=))<..\set.txt
  7. set win=%line%
  8. echo %MT%
  9. echo %win%
  10. pause
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2