staruhub/ClaudeSkills / skills/Geek-skills-c-drive-cleaner
c-drive-cleaner
VerifiedWindows C盘清理和磁盘空间管理。当用户说C盘满了、磁盘空间不足、清理临时文件/缓存/回收站/系统日志、查找大文件、分析磁盘占用时使用。仅适用于 Windows 环境。不用于:macOS/Linux 磁盘清理、卸载软件(引导用户走系统卸载)、清理用户个人文件(只报告位置,删除决定权在用户)。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.7 KB |
| references/windows_cleanup_guide.md | markdown | 6.0 KB |
| scripts/analyze_disk.py | script | 3.8 KB |
| scripts/clean_temp.py | script | 8.7 KB |
| scripts/find_large_files.py | script | 5.5 KB |
scripts/analyze_disk.py
View on GitHub#!/usr/bin/env python3
"""
分析磁盘空间使用情况,找出占用空间最大的目录和文件
"""
import os
import sys
from pathlib import Path
from collections import defaultdict
def get_size(path):
"""获取文件或目录的大小"""
try:
if os.path.isfile(path):
return os.path.getsize(path)
elif os.path.isdir(path):
total = 0
try:
for entry in os.scandir(path):
try:
if entry.is_file(follow_symlinks=False):
total += entry.stat(follow_symlinks=False).st_size
elif entry.is_dir(follow_symlinks=False):
total += get_size(entry.path)
except (PermissionError, FileNotFoundError, OSError):
continue
except (PermissionError, FileNotFoundError, OSError):
pass
return total
except (PermissionError, FileNotFoundError, OSError):
return 0
def format_size(size):
"""格式化文件大小为人类可读格式"""
for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
if size < 1024.0:
return f"{size:.2f} {unit}"
size /= 1024.0
return f"{size:.2f} PB"
def analyze_directory(root_path, max_depth=2, top_n=20):
"""
分析目录结构,找出最大的子目录和文件
Args:
root_path: 要分析的根目录路径
max_depth: 最大扫描深度
top_n: 返回前N个最大项
"""
dir_sizes = {}
large_files = []
print(f"正在分析 {root_path} ...")
print(f"扫描深度: {max_depth} 层")
print("-" * 80)
try:
# 分析一级子目录
for entry in os.scandir(root_path):
try:
if entry.is_dir(follow_symlinks=False):
size = get_size(entry.path)
dir_sizes[entry.path] = size
print(f"扫描: {entry.name} ... {format_size(size)}")
elif entry.is_file(follow_symlinks=False):
size = entry.stat(follow_symlinks=False).st_size
if size > 100 * 1024 * 1024: # 大于100MB的文件
large_files.append((entry.path, size))
except (PermissionError, FileNotFoundError, OSError) as e:
print(f"跳过 {entry.name}: 无权限访问")
continue
except (PermissionError, FileNotFoundError, OSError) as e:
print(f"无法访问 {root_path}: {e}")
return
# 输出结果
print("\n" + "=" * 80)
print(f"📊 前 {top_n} 个最大目录:")
print("=" * 80)
sorted_dirs = sorted(dir_sizes.items(), key=lambda x: x[1], reverse=True)[:top_n]
for path, size in sorted_dirs:
print(f"{format_size(size):>15} - {path}")
if large_files:
print("\n" + "=" * 80)
print(f"📄 大文件 (>100MB):")
print("=" * 80)
sorted_files = sorted(large_files, key=lambda x: x[1], reverse=True)[:top_n]
for path, size in sorted_files:
print(f"{format_size(size):>15} - {path}")
# 输出总计
total_size = sum(dir_sizes.values())
print("\n" + "=" * 80)
print(f"总计扫描空间: {format_size(total_size)}")
print("=" * 80)
def main():
if len(sys.argv) < 2:
print("使用方法: python analyze_disk.py <目录路径> [扫描深度] [显示数量]")
print("示例: python analyze_disk.py C:\\ 2 20")
sys.exit(1)
root_path = sys.argv[1]
max_depth = int(sys.argv[2]) if len(sys.argv) > 2 else 2
top_n = int(sys.argv[3]) if len(sys.argv) > 3 else 20
if not os.path.exists(root_path):
print(f"错误: 路径不存在: {root_path}")
sys.exit(1)
analyze_directory(root_path, max_depth, top_n)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |