-
- @echo off && setlocal enabledelayedexpansion
- call :i l +
- call :i r -
- set /a r+=1
- for /f %%a in (1.txt) do set "v=%%a" && echo !v:~%l%,%r%!>>2.txt
- goto :eof
-
- :i
- set "?=%2"
- set "s="
- if "%?%"=="+" (set i=0) else (set i=-1)
- :repeat
- for /f %%a in (1.txt) do set "v=%%a" && set "s=!s!!v:~%i%,1!"
- set "v=!v:~%i%,1!"
- set "s=!s:%v%=!"
- if not defined s (set /a i%?%=1 && goto repeat) else (set %1=%i%)
复制代码
|