@echo off setlocal enabledelayedexpansion
%1(for /f "delims=" %%i in ('%~0 :^|sort') do ren %%i) pause exit /b
for /f "tokens=1,* delims= " %%i in ('find /c /v "" *.txt') do (
set info=%%j
set ln=!info:*:=!
for /f "delims=" %%a in ("!ln!") do set fn=!info::%%a=!
echo;"!fn!" "!fn:~,-4!!ln:~1!.txt"
)