@echo off
setlocal enabledelayedexpansion
set /a sum=0
set pt=
set ext=*
set ml=dpnx
if "%~1" == "-h" goto help
if "%~1" == "-help" goto help
if "%~1" == "-?" goto help
if "%~1" == "/?" goto help
echo %~1|findstr /i echo>nul && goto help
if not "%~1" == "*" if exist "%~1" set pt=%~1\
if not "%~2" == "*" if exist "%~2" set pt=%~2\
if not "%~3" == "*" if exist "%~3" set pt=%~3\
if not "%~4" == "*" if exist "%~4" set pt=%~4\
echo %~1|findstr \/>nul|| if not exist "%~1" set ext=%~1
echo %~2|findstr /i echo>nul || echo %~2|findstr \/>nul || if not exist "%~2" set ext=%~2
echo %~3|findstr /i echo>nul || echo %~3|findstr \/>nul || if not exist "%~3" set ext=%~3
echo %~4|findstr /i echo>nul || echo %~4|findstr \/>nul || if not exist "%~4" set ext=%~4
echo %~1|findstr \/>nul && set ml=%~1>nul
echo %~2|findstr \/>nul && set ml=%~2>nul
echo %~3|findstr \/>nul && set ml=%~3>nul
echo %~4|findstr \/>nul && set ml=%~4>nul
set ml=%ml:/=%
for /f "delims=" %%i in ('dir "%pt%*.%ext%" /a /b /s') do (echo %%~%ml%i & set /a sum=!sum!+1)
echo.
echo 共 %sum% 个文件!!!
endlocal
goto:eof
:help
echo -------------------------------------------------------------
echo fxs (files' extension searcher)
echo 搜索指定扩展名的文件搜索指定扩展名的文件并统计文件个数。
echo.
echo fxs [盘符及路径] [后缀名] [/命令]
echo.
echo [盘符及路径]可选,默认当前。
echo.
echo 后缀名 可选输入,可以使用通配符 * 或 ? 默认为:*
echo * 表示所有扩展名
echo ? 表示一个通配字符
echo.
echo [-命令] 包括:d p n x t z a;此选项可选,默认为 /dpnx
echo 选项 d 显示盘符
echo 选项 p 显示路径
echo 选项 n 显示文件名
echo 选项 x 显示文件扩展名
echo 选项 t 显示文件修改时间
echo 选项 z 显示文件大小
echo 选项 a 显示文件属性
echo 选项 f 显示完整路径及文件名
echo 以上命令选项可以组合使用,例如要显示 C:\windows 下的
echo 所有,txt文档的【名称,路径,大小】输入命令:
echo fxs c:\windows txt /pnz
echo.
echo 可以与 more 命令配合使用,逐屏输出结果。
echo fxs c:\windows txt /pn^|more
echo ---------------------------------------------------------------
网友评论