mac-cleaner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMac Cleaner
Mac Cleaner
扫描和清理 macOS 系统垃圾文件,帮助释放磁盘空间。
Scan and clean junk files on macOS systems to help free up disk space.
快速开始
Quick Start
使用以下命令扫描不同类型的垃圾文件:
bash
undefinedUse the following commands to scan different types of junk files:
bash
undefined扫描系统缓存和临时文件
Scan system cache and temporary files
bash .claude/skills/mac-cleaner/scripts/scan_cache.sh
bash .claude/skills/mac-cleaner/scripts/scan_cache.sh
扫描开发临时文件和构建产物 (node_modules, .next, dist 等)
Scan development temporary files and build artifacts (node_modules, .next, dist, etc.)
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh /path/to/scan
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh /path/to/scan
扫描重复文件 (需要先安装 fdupes: brew install fdupes)
Scan duplicate files (requires fdupes to be installed first: brew install fdupes)
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh /path/to/scan
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh /path/to/scan
扫描大文件 (默认 > 100MB)
Scan large files (default > 100MB)
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh /path/to/scan 100M 20
undefinedbash .claude/skills/mac-cleaner/scripts/scan_large_files.sh /path/to/scan 100M 20
undefined扫描类型
Scan Types
1. 系统缓存文件
1. System Cache Files
扫描包括:
- - 用户缓存
~/Library/Caches - - 系统缓存
/Library/Caches - - 用户日志
~/Library/Logs - - 系统日志
/Library/Logs - - 回收站
~/.Trash - - 临时文件
/tmp
脚本:
scan_cache.sh使用场景:
- 系统运行缓慢
- 应用程序出现异常
- 定期清理系统
注意事项:
- 删除系统缓存需要 sudo 权限
- 删除后首次运行应用可能会变慢(需要重建缓存)
- 建议先备份重要数据
Scans include:
- - User cache
~/Library/Caches - - System cache
/Library/Caches - - User logs
~/Library/Logs - - System logs
/Library/Logs - - Trash
~/.Trash - - Temporary files
/tmp
Script:
scan_cache.shUsage Scenarios:
- Slow system performance
- Application exceptions
- Regular system maintenance
Notes:
- Deleting system cache requires sudo privileges
- Applications may run slowly the first time after deletion (cache needs to be rebuilt)
- It is recommended to back up important data first
2. 开发临时文件
2. Development Temporary Files
扫描包括:
- - Node.js 依赖
node_modules - - Next.js 构建产物
.next - /
dist- 前端构建产物build - - Java/Scala 编译产物
target - /
__pycache__- Python 缓存*.pyc - - macOS 系统文件
.DS_Store - - 日志文件
*.log
脚本:
scan_dev_files.sh参数:
- 第一个参数: 扫描目录 (默认当前目录)
- 第二个参数: 最大深度 (默认 3 层)
使用场景:
- 开发项目占用大量空间
- 切换分支前清理构建产物
- 清理不再使用的项目依赖
示例:
bash
undefinedScans include:
- - Node.js dependencies
node_modules - - Next.js build artifacts
.next - /
dist- Frontend build artifactsbuild - - Java/Scala compilation artifacts
target - /
__pycache__- Python cache*.pyc - - macOS system files
.DS_Store - - Log files
*.log
Script:
scan_dev_files.shParameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Maximum depth (default 3 levels)
Usage Scenarios:
- Development projects taking up too much space
- Clean up build artifacts before switching branches
- Clean up unused project dependencies
Examples:
bash
undefined扫描当前目录
Scan current directory
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh
扫描指定目录,深度为 2
Scan specified directory with depth 2
bash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh ~/projects 2
undefinedbash .claude/skills/mac-cleaner/scripts/scan_dev_files.sh ~/projects 2
undefined3. 重复文件
3. Duplicate Files
使用 工具查找重复文件。
fdupes脚本:
scan_duplicates.sh前提条件:
bash
brew install fdupes参数:
- 第一个参数: 扫描目录 (默认当前目录)
- 第二个参数: 最小文件大小 (默认 1M)
使用场景:
- 备份文件重复
- 下载文件重复
- 项目资源文件重复
示例:
bash
undefinedUse the tool to find duplicate files.
fdupesScript:
scan_duplicates.shPrerequisites:
bash
brew install fdupesParameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Minimum file size (default 1M)
Usage Scenarios:
- Duplicate backup files
- Duplicate downloaded files
- Duplicate project resource files
Examples:
bash
undefined扫描当前目录中大于 1MB 的重复文件
Scan duplicate files larger than 1MB in current directory
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh
扫描指定目录中大于 10MB 的重复文件
Scan duplicate files larger than 10MB in specified directory
bash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh ~/Documents 10M
**清理命令**:
```bashbash .claude/skills/mac-cleaner/scripts/scan_duplicates.sh ~/Documents 10M
**Cleanup Commands**:
```bash交互式删除 (保留每个重复组的第一个文件)
Interactive deletion (keep the first file in each duplicate group)
fdupes -r -d -N /path/to/scan
undefinedfdupes -r -d -N /path/to/scan
undefined4. 大文件
4. Large Files
查找占用大量空间的文件。
脚本:
scan_large_files.sh参数:
- 第一个参数: 扫描目录 (默认当前目录)
- 第二个参数: 最小文件大小 (默认 100M)
- 第三个参数: 显示前 N 个文件 (默认 20)
使用场景:
- 磁盘空间不足
- 查找可以删除的大文件
- 分析磁盘空间占用
示例:
bash
undefinedLocate files that take up a lot of space.
Script:
scan_large_files.shParameters:
- First parameter: Scan directory (default current directory)
- Second parameter: Minimum file size (default 100M)
- Third parameter: Show top N files (default 20)
Usage Scenarios:
- Insufficient disk space
- Find large files that can be deleted
- Analyze disk space usage
Examples:
bash
undefined查找大于 100MB 的文件,显示前 20 个
Find files larger than 100MB, show top 20
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh
查找大于 1GB 的文件,显示前 10 个
Find files larger than 1GB, show top 10
bash .claude/skills/mac-cleaner/scripts/scan_large_files.sh ~/Documents 1G 10
undefinedbash .claude/skills/mac-cleaner/scripts/scan_large_files.sh ~/Documents 1G 10
undefined清理流程
Cleanup Process
所有扫描脚本都会提供清理命令建议。遵循以下安全流程:
All scan scripts will provide cleanup command recommendations. Follow this safe process:
步骤 1: 扫描
Step 1: Scan
首先使用相应的脚本扫描目标目录,识别垃圾文件。
First use the corresponding script to scan the target directory and identify junk files.
步骤 2: 检查结果
Step 2: Review Results
仔细检查扫描结果,确认要删除的文件:
- 确认文件确实不再需要
- 检查是否有重要数据
- 验证删除不会影响其他程序
Carefully review the scan results and confirm the files to delete:
- Confirm the files are no longer needed
- Check for important data
- Verify deletion will not affect other programs
步骤 3: 备份 (可选)
Step 3: Backup (Optional)
对于重要文件,建议先备份:
bash
undefinedFor important files, it is recommended to back up first:
bash
undefined创建备份
Create backup
cp -r /path/to/important/file ~/backup/
cp -r /path/to/important/file ~/backup/
或使用 tar 打包
Or use tar to package
tar -czf backup_$(date +%Y%m%d).tar.gz /path/to/file
undefinedtar -czf backup_$(date +%Y%m%d).tar.gz /path/to/file
undefined步骤 4: 删除
Step 4: Delete
使用脚本提供的清理命令,或手动删除:
bash
undefinedUse the cleanup commands provided by the script, or delete manually:
bash
undefined删除单个文件/目录
Delete single file/directory
rm -rf /path/to/file
rm -rf /path/to/file
删除多个文件
Delete multiple files
rm -rf file1 file2 file3
rm -rf file1 file2 file3
使用 find 批量删除
Use find to delete in batches
find . -name "node_modules" -type d -prune -exec rm -rf {} +
undefinedfind . -name "node_modules" -type d -prune -exec rm -rf {} +
undefined最佳实践
Best Practices
开发项目清理
Development Project Cleanup
对于开发项目,建议使用 防止提交临时文件:
.gitignoregitignore
node_modules/
.next/
dist/
build/
__pycache__/
*.pyc
.DS_Store
*.log清理项目前,可以使用:
bash
undefinedFor development projects, it is recommended to use to prevent committing temporary files:
.gitignoregitignore
node_modules/
.next/
dist/
build/
__pycache__/
*.pyc
.DS_Store
*.logBefore cleaning up the project, you can use:
bash
undefined保存依赖列表
Save dependency list
npm list > dependencies.txt
npm list > dependencies.txt
删除 node_modules
Delete node_modules
rm -rf node_modules
rm -rf node_modules
需要时恢复
Restore when needed
npm install
undefinednpm install
undefined定期清理
Regular Cleanup
建议定期(每月或每季度)运行清理:
- 清空回收站
- 清理浏览器缓存
- 删除开发构建产物
- 查找并删除重复文件
It is recommended to run cleanup regularly (monthly or quarterly):
- Empty Trash
- Clear browser cache
- Delete development build artifacts
- Find and delete duplicate files
系统缓存清理
System Cache Cleanup
系统缓存清理需谨慎:
- 只删除已知安全的缓存
- 避免删除正在使用的缓存
- 删除后可能需要重启应用
System cache cleanup requires caution:
- Only delete known safe caches
- Avoid deleting caches that are in use
- Applications may need to be restarted after deletion
安全警告
Safety Warnings
⚠️ 重要提示:
- 删除操作不可逆,请仔细确认
- 系统文件和缓存删除需要 sudo 权限,需格外谨慎
- 删除前建议备份重要数据
- 不确定文件用途时,请先查询或咨询
- 某些缓存删除后首次运行应用会变慢
⚠️ Important Notes:
- Deletion operations are irreversible, please confirm carefully
- Deleting system files and caches requires sudo privileges, extra caution is needed
- It is recommended to back up important data before deletion
- If you are unsure about the purpose of a file, please query or consult first
- Some applications may run slowly the first time after cache deletion
故障排除
Troubleshooting
fdupes 未安装
fdupes Not Installed
如果使用重复文件扫描时提示 fdupes 未安装:
bash
brew install fdupesIf you get a prompt that fdupes is not installed when using duplicate file scanning:
bash
brew install fdupes权限不足
Insufficient Permissions
某些系统目录需要 sudo 权限:
bash
sudo bash .claude/skills/mac-cleaner/scripts/scan_cache.shSome system directories require sudo privileges:
bash
sudo bash .claude/skills/mac-cleaner/scripts/scan_cache.sh扫描速度慢
Slow Scanning
对于大型目录:
- 限制扫描深度
- 增加最小文件大小限制
- 分目录扫描
For large directories:
- Limit scan depth
- Increase minimum file size limit
- Scan directories separately
资源
Resources
scripts/
scripts/
- - 扫描系统缓存和临时文件
scan_cache.sh - - 扫描开发临时文件和构建产物
scan_dev_files.sh - - 扫描重复文件
scan_duplicates.sh - - 扫描大文件
scan_large_files.sh - - 生成带确认的安全删除脚本
generate_cleanup_commands.sh
- - Scan system cache and temporary files
scan_cache.sh - - Scan development temporary files and build artifacts
scan_dev_files.sh - - Scan duplicate files
scan_duplicates.sh - - Scan large files
scan_large_files.sh - - Generate safe deletion scripts with confirmation
generate_cleanup_commands.sh