Install
Install with PiG
pig install npm:@pengpeng42/pi-file-statsInstall with Pi
pi install npm:@pengpeng42/pi-file-statsPackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./extensions/file-stats.ts"
]
}README
Written by the package's publisher, shown as published in version 1.0.0 (README.md). PiG does not review it.
# pi-file-stats
一个用于统计目录文件信息的 Pi 扩展。
## 功能
- 递归统计目录及子目录中的文件。
- 返回文件总数、总字节数和各扩展名的文件数量。
- 跳过符号链接。
- 无扩展名的文件归入 (no extension)。
## 本地试用
在包目录中运行:
pi -e .
进入 Pi 后输入:
请调用 file\_stats 工具,统计 ./stats-demo 目录。
stats-demo 是测试目录,使用时可替换成自己的目录路径。
## 工具参数
- directory:需要统计的目录,支持绝对路径或相对于 Pi 当前工作目录的路径。
## 返回字段
- directory:实际统计的目录。
- fileCount:文件总数。
- totalBytes:文件总字节数。
- byExtension:各扩展名对应的文件数量。
## 测试记录
在 Windows PowerShell、Pi 1.3.0 环境下完成测试。
测试目录包含两个 txt 文件和子目录中的一个 md 文件。
返回结果为 3 个文件、12 字节,与预期一致。