@echo off
setlocal
echo Unsorted:
for %%A in (*.pdf) do echo %%A
echo.
echo Sorted:
(
for %%G in (*.pdf) do @(
set "file= %%~G"
call set "file=%%file:~-14%%"
call echo %%file%%
)
) | for /f "tokens=*" %%A in ('sort') do @echo %%A
Pads each filename with 10 spaces and then trims to last 14 characters
which should be within the 32 bit number range. It is piped to a
for loop to sort which gets them in order like explorer. The
tokens=*
option removes the leading spaces. call set
and
call echo
expands the doubled percentage variables inside a code
block which saves using delayed expansion.
Output:
Unsorted:
1.pdf
11.pdf
2.pdf
22.pdf
Sorted:
1.pdf
2.pdf
11.pdf
22.pdf
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…