mitrichbel Пробуй следующий код (работает медленнее предыдущего, так что прежде чем он выдаст результат, может пройти минута-две)
:
Код: @echo off
setlocal enabledelayedexpansion
echo.
del /q /f "%temp%\fext.txt" 2>nul
del /q /f "%temp%\sext.txt" 2>nul
for /r %%a in (*.txt) do call :check %%~na
for /f "usebackq" %%a in ("%temp%\sext.txt") do (
echo Files grouped by "%%a" ending:
dir /s /b "* %%a.txt"
echo.
)
del /q /f "%temp%\fext.txt" 2>nul
del /q /f "%temp%\sext.txt" 2>nul
goto :EOF
:check
::maybe we've found last two part of filename
if "%3"=="" (
::if it realy consists of two parts
if not "%2"=="" (
set "test2=no"
set "test=%2"
::if second part is not zero
if not !test!==0 ( set /a "test1=!test!-1"
::if the result is -1 - it's not a number
if not !test1!==-1 (set "test2=yes")
) else (
::if the second part is zero - OK, it's a number
set "test2=yes")
::if we found number
if !test2!==yes (
::check whether it is already in the list
find "%2" "%temp%\fext.txt">nul 2>nul
::if not - add it to the list
if not !errorlevel!==0 (echo.%2>>"%temp%\fext.txt") else (
find "%2" "%temp%\sext.txt">nul 2>nul
if not !errorlevel!==0 (echo.%2>>"%temp%\sext.txt")
)
)
)
) else (
::the filename has more then 2 parts - shift it by 1 position to the left
shift
::try again
goto check
)