本帖最后由 qixiaobin0715 于 2020-11-12 13:17 编辑
练练手,去掉一层for循环,复习一下call的用法,效率差点。- @echo off
- setlocal enabledelayedexpansion
- for /r %%i in ("*.txt") do (
- set n=0
- for /f "delims=" %%a in ('type "%%i"^|findstr /c:"img alt"') do (
- set "str=%%a"
- :a
- echo "!str!"|findstr /c:"img alt">nul&&set str=!str:*img alt=!&&set /a n+=1&&call :a
- )
- ren "%%i" "%%~ni(共!n!张图片)%%~xi" 2>nul
- )
- goto :eof
复制代码
|