以文件名长度升序列示指定文件- @echo off
- rem 保存为ANSI格式
- setlocal enabledelayedexpansion
- set "_strlen=set $=^!#1^!#&set ##=&(for %%a in (256 128 64 32 16)do if ^!$:~%%a^!. NEQ . set/a##+=%%a&set $=^!$:~%%a^!)&set $=^!$^!fedcba9876543210&set/a##+=0x^!$:~16,1^!&set ##= ^!##^!&set ##=^!##:~-3^!"
- set /a No=0
- (for /f "tokens=*" %%a in ('dir "%~1" /b/s/a-d') do (
- if "%%~fa" NEQ "%~f0" (
- set "#1=%%~na"
- (%_strlen%)
- set Nl=!##!
- set "#1=%%~fa"
- (%_strlen%)
- echo;!Nl!(!##!) "%%~na" ( "%%~fa" )
- set /a No+=1
- )
- ))>"%~dpn0.bak"
- echo;长度 文件名 (...)>"%~dpn0.txt"
- sort "%~dpn0.bak">>"%~dpn0.txt"
- del "%~dpn0.bak"
- if %No% GEQ 1 (echo;&echo;共 %No% 个文件)>>"%~dpn0.txt"
- type "%~dpn0.txt"
- echo;&echo;详情见"%~dpn0.txt"
- endlocal
- echo;&pause
- exit /b
复制代码 拖放目标到脚本即可。 |