@echo offset arg=%1if "%arg%" == "" set arg=*if "%arg%" == "-h" ( echo sort by numbers in filename echo usage: nsort [drive:][path][filename] exit /b)setlocal EnableExtensionsfor /F "delims=" %%I in ('dir %arg% /A-D /B /ON 2^>nul') do call :AddToFileList "%%I"for /F "tokens=1* delims==" %%I in ('set FileList[ 2^>nul') do echo %%Jendlocalexit /B:AddToFileListset "FileName=%~n1"if "%FileName%" == "" set "FileName=%~x1"set "FileNumber=":GetFileNumberfor /F "delims=0123456789" %%I in ("%FileName:~-1%") do goto AddFileToArrayset "FileNumber=%FileName:~-1%%FileNumber%"set "FileName=%FileName:~0,-1%"if not "%FileName%" == "" goto GetFileNumber:AddFileToArrayset "FileNumber=00000%FileNumber%"set "FileNumber=%FileNumber:~-5%"set "FileList[%FileName%_%FileNumber%]=%~1"goto :EOF