本帖最后由 buyiyang 于 2022-4-2 00:55 编辑
- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- for %%i in (*.txt) do (
- for /f "delims=" %%a in ('type "%%i"') do (set /p=%%a#<nul>>by.txt)
- for /f "delims=" %%b in (by.txt) do set "str=%%b"&&set "str=!str:----------#==!"
- for %%c in (!str!) do echo %%c>>byy.txt
- sort byy.txt >by.txt
- cd.>byy.txt
- for /f "delims=" %%x in ('type by.txt') do echo ----------#%%x>>byy.txt
- cd.>by.txt
- for /f "delims=" %%y in (byy.txt) do (
- set "strr=%%y"&&set "strr=!strr:#==!"
- for %%z in (!strr!) do >> by.txt echo,%%z
- )
- copy /y by.txt "%%~ni-1.txt"
- echo %%~ni-1.txt
- del /q by.txt
- del /q byy.txt
- )
- echo 按任意键结束&pause>nul
复制代码 水平有限,用的笨办法。希望你的目录下没有by.txt,byy.txt文件。 |