Files
disk-scanner/README.md
hubian 4ce1c93ad3 feat: 磁盘大文件扫描工具 v1.0.0
功能:
- 智能跳过零碎目录 (node_modules, .git, venv等)
- 文件数量阈值判断
- 大小阈值过滤
- 按大小排序展示
- 树形结构清晰展示
- 支持Windows/Linux/macOS
2026-04-12 16:22:01 +08:00

122 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 磁盘大文件扫描工具
智能扫描Windows目录快速定位大文件和大目录自动跳过零碎文件目录。
## 功能特点
-**智能跳过零碎目录**:自动识别 `node_modules``.git``venv`、缓存目录等
-**文件数量阈值**:目录内文件数超过阈值,视为"程序包",整体显示但不展开
-**大小阈值过滤**:小目录自动折叠,聚焦大文件
-**按大小排序**:优先展示占用空间最大的文件/目录
-**树形结构展示**:清晰的层级关系
-**跨平台**Windows/Linux/macOS 均可使用
## 使用方法
### Windows
双击 `disk_scanner.bat` 或在命令行运行:
```batch
# 扫描当前目录
disk_scanner.bat .
# 扫描指定目录
disk_scanner.bat C:\Users
# 限制深度3层
disk_scanner.bat D:\ -d 3
# 自定义阈值
disk_scanner.bat "C:\Program Files" -f 200 -s 50M
```
### Linux/macOS 或直接用Python
```bash
# 扫描当前目录
python disk_scanner.py .
# 扫描指定目录
python disk_scanner.py /home/user
# 限制深度
python disk_scanner.py /var -d 3
```
## 参数说明
| 参数 | 简写 | 默认值 | 说明 |
|------|------|--------|------|
| `path` | - | 必填 | 要扫描的目录路径 |
| `--depth` | `-d` | 无限制 | 最大扫描深度 |
| `--top` | `-n` | 20 | 每层显示前N个条目 |
| `--file-threshold` | `-f` | 100 | 文件数阈值,超过视为零碎目录 |
| `--size-threshold` | `-s` | 10M | 大小阈值,小于此值不深入 |
## 自动跳过的目录
工具会自动跳过以下类型的目录深入扫描:
**依赖/包管理**
- `node_modules`, `.npm`, `.yarn`
- `venv`, `env`, `site-packages`
- `target`, `build`, `dist`
- `vendor`, `Pods`
**版本控制**
- `.git`, `.svn`, `.hg`
**IDE/编辑器**
- `.idea`, `.vscode`, `.vs`
**缓存/临时**
- `.cache`, `__pycache__`, `tmp`
这些目录仍会显示总大小,但不会展开列出内部文件。
## 输出示例
```
============================================================
磁盘空间扫描报告
============================================================
目标: C:\Users\xxx\Projects
文件数阈值: 100 (超过视为零碎目录)
大小阈值: 10.0MB (小于此值不深入)
============================================================
📁 C:\Users\xxx\Projects
总大小: 15.2GB
------------------------------------------------------------
├── 📁 project-a: 8.5GB
│ ├── 📦 node_modules [15234 files, skipped]: 6.2GB
│ ├── 📁 src: 1.2GB
│ │ ├── 📄 assets.mp4: 450.0MB
│ │ └── 📁 components: 380.0MB
│ └── 📄 database.db: 2.1GB
├── 📁 project-b: 4.8GB
│ └── 📦 venv [2345 files, skipped]: 1.2GB
└── 📄 backup.zip: 1.9GB
```
## 自定义配置
如需添加其他跳过的目录模式,编辑 `disk_scanner.py` 中的 `SKIP_PATTERNS` 集合:
```python
SKIP_PATTERNS = {
'node_modules', '.git', 'venv',
# 添加你的自定义模式
'my_cache_dir',
}
```
## 系统要求
- Python 3.6+
- 无需安装额外依赖(仅使用标准库)
## 版本
v1.0.0 - 初始版本