本帖最后由 yhcfsr 于 2018-1-11 17:22 编辑
- @echo off
- set "ScDir=D:\temp"
- set "spt=原标题"
- cd /d "%ScDir%"&cd.>"%ScDir%\error.log"
- for /f "delims=" %%a in ('dir /a-d /s /b *.txt') do (
- for /f "delims=" %%i in ('findstr /n .* "%%a"') do set "var=%%i"
- setlocal enableDelayedExpansion
- set "tmp=!var!"
- set "var=!var:*%spt%=!"
- if !var! neq !tmp! (ren "%%a" "!var!%%~xa") else (echo %%~a>>"%ScDir%\error.log")
- endlocal
- )
- pause
- exit
复制代码
|