- @echo off
- set/a n=1000
- for %%a in (*.txt) do (
- for /f "delims=" %%b in ('findstr/n ".*" "%%~a"') do (
- set "str=%%b"&setlocal enabledelayedexpansion
- set "str=!str:*:=!"
- if not defined flag (>%%a echo %%~na&>>%%a echo/!str!) else (>>%%a echo/!str!)
- endlocal&set flag=a
- )
- set "flag="&call :_ren "%%a"
- )
- pause&exit
- ::重命名
- :_ren
- set/a n+=1
- if not exist %n:~1%.txt (ren %1 "%n:~1%.txt") else goto _ren
复制代码
|