← Back to Skills Marketplace
62
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install laosi-file-organizer
Description
文件整理 - 桌面和下载文件夹一键自动归类:图片/文档/压缩包/视频/音频/代码,生成整理报告
README (SKILL.md)
File Organizer - 文件整理
激活词: 整理 / 文件整理 / 归类
有什么用
桌面和下载文件夹是数字世界的玄关。乱成一团时,一键按类型自动归类,找回文件不用再翻遍整个文件夹。
Python 实现
import os
import shutil
from datetime import datetime
class FileOrganizer:
CATEGORIES = {
"Images": [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg",
".ico", ".tiff", ".tif", ".raw", ".heic", ".avif"],
"Documents": [".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx",
".txt", ".md", ".rst", ".csv", ".tsv", ".json", ".xml",
".yaml", ".yml", ".toml", ".ini", ".cfg", ".conf",
".epub", ".mobi", ".pages", ".numbers", ".key"],
"Archives": [".zip", ".rar", ".7z", ".tar", ".gz", ".bz2", ".xz",
".zst", ".iso", ".dmg"],
"Videos": [".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm",
".m4v", ".mpeg", ".mpg", ".3gp"],
"Audio": [".mp3", ".wav", ".flac", ".aac", ".ogg", ".wma", ".m4a",
".opus", ".alac"],
"Code": [".py", ".js", ".ts", ".jsx", ".tsx", ".html", ".htm", ".css",
".scss", ".less", ".java", ".cpp", ".c", ".h", ".hpp",
".go", ".rs", ".rb", ".php", ".swift", ".kt", ".scala",
".sh", ".bat", ".ps1", ".sql", ".r", ".lua", ".pl",
".dart", ".vue", ".svelte", ".astro"],
"Executables": [".exe", ".msi", ".appimage", ".deb", ".rpm",
".dll", ".so", ".dylib"],
"Fonts": [".ttf", ".otf", ".woff", ".woff2", ".eot"],
}
def __init__(self, target_dirs: list = None):
self.target_dirs = target_dirs or [
os.path.join(os.environ.get("USERPROFILE", "C:/Users/Default"), "Downloads"),
os.path.join(os.environ.get("USERPROFILE", "C:/Users/Default"), "Desktop"),
]
def organize(self, dry_run: bool = False) -> dict:
"""执行整理,dry_run=True 只预览不动手"""
report = {
"scanned_dirs": [],
"total_scanned": 0,
"organized": 0,
"skipped": 0,
"by_category": {},
"errors": []
}
for target in self.target_dirs:
if not os.path.exists(target):
report["errors"].append(f"目录不存在: {target}")
continue
dir_name = os.path.basename(target)
report["scanned_dirs"].append(target)
items = [f for f in os.listdir(target)
if os.path.isfile(os.path.join(target, f))]
report["total_scanned"] += len(items)
for fname in items:
fpath = os.path.join(target, fname)
ext = os.path.splitext(fname)[1].lower()
category = self._classify(ext)
if category:
cat_dir = os.path.join(target, f"_{category}")
if not dry_run:
os.makedirs(cat_dir, exist_ok=True)
try:
shutil.move(fpath, os.path.join(cat_dir, fname))
report["organized"] += 1
report["by_category"][category] = report["by_category"].get(category, 0) + 1
except (shutil.Error, PermissionError) as e:
report["errors"].append(f"移动失败: {fname} -> {e}")
report["skipped"] += 1
else:
report["organized"] += 1
report["by_category"][category] = report["by_category"].get(category, 0) + 1
else:
report["skipped"] += 1
report["timestamp"] = datetime.now().isoformat()
return report
def _classify(self, ext: str) -> str:
for cat, exts in self.CATEGORIES.items():
if ext in exts:
return cat
return ""
def print_report(self, report: dict):
print(f"\
{'='*40}")
print(f"文件整理报告 ({report['timestamp']})")
print(f"{'='*40}")
for d in report["scanned_dirs"]:
print(f" 扫描: {d}")
print(f"\
总计扫描: {report['total_scanned']} 个文件")
print(f" 已整理: {report['organized']} 个")
print(f" 已跳过: {report['skipped']} 个")
if report["by_category"]:
print(f"\
分类统计:")
for cat, count in sorted(report["by_category"].items(), key=lambda x: -x[1]):
print(f" {cat}: {count} 个")
if report["errors"]:
print(f"\
错误 ({len(report['errors'])}):")
for e in report["errors"][:5]:
print(f" ❌ {e}")
# 使用示例
organizer = FileOrganizer()
# 先预览,不实际移动
report = organizer.organize(dry_run=True)
organizer.print_report(report)
# 确认后执行
# organizer.organize(dry_run=False)
分类规则
| 分类 | 后缀 | 目录名 |
|---|---|---|
| 🖼 图片 | jpg, png, gif, webp, svg... | _Images |
| 📄 文档 | pdf, doc, txt, md, csv... | _Documents |
| 📦 压缩包 | zip, rar, 7z, tar.gz... | _Archives |
| 🎬 视频 | mp4, avi, mkv, mov... | _Videos |
| 🎵 音频 | mp3, wav, flac, aac... | _Audio |
| 💻 代码 | py, js, ts, html, css... | _Code |
| ⚙️ 可执行 | exe, msi, deb, dll... | _Executables |
| 🔤 字体 | ttf, otf, woff... | _Fonts |
安全机制
- 只会将文件移动到
_分类名子目录,不会删除任何文件 - 同名文件冲突时保留原有文件(
shutil.move会报错不会覆盖) - 只处理文件,不会移动其他目录
dry_run=True模式零修改,先预览再执行
使用场景
- 桌面清理: 每周一键整理桌面
- 下载清理: 下载文件夹攒了几个月的东西一键分类
- 迁移助手: 换电脑时把文件分类后打包
- 开发者: 代码文件
.py .js .json自动归入Code目录
命令行用法
# 预览整理结果
python -c "from file_organizer import FileOrganizer; FileOrganizer().print_report(FileOrganizer().organize(dry_run=True))"
# 执行整理
python -c "from file_organizer import FileOrganizer; FileOrganizer().organize(dry_run=False)"
依赖
- Python 3.8+
- 无第三方依赖
Usage Guidance
Use the dry-run preview first and review the report before executing real moves. Install only if you are comfortable with a helper that can reorganize files in Desktop and Downloads into category subfolders.
Capability Assessment
Purpose & Capability
The stated purpose is file organization, and the provided Python implementation only classifies files by extension and moves matching top-level files into category subfolders.
Instruction Scope
The skill discloses preview mode and execution mode, but its activation terms are short and generic, so users should be explicit before allowing real file moves.
Install Mechanism
The artifact contains only a SKILL.md document with example Python code; no executable installer, dependency package, or hidden install step is present.
Credentials
Access is scoped to the user's Desktop and Downloads folders by default, with no network calls, credential access, broad indexing, or unrelated data collection.
Persistence & Privilege
No persistence, background process, privilege escalation, startup modification, or deletion behavior is shown; file changes are limited to moving files when explicitly run with dry_run=False.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install laosi-file-organizer - After installation, invoke the skill by name or use
/laosi-file-organizer - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.1.0
Summary: Added detailed usage guide and Python implementation to documentation.
- Expanded SKILL.md with full Python implementation, including safety checks and report generation.
- Added usage examples, command-line instructions, and dry-run explanation.
- Extended classification to more file types and added new categories (Executables, Fonts).
- Improved documentation of classification rules and safety mechanisms.
- Specified dependencies and use cases for better clarity.
v1.0.0
Initial release of file-organizer:
- Automatically organizes files on Desktop and Downloads folders by type.
- Supported categories: images, documents, archives, videos, audio, and code.
- Files are moved into corresponding "_分类名" (category) subfolders.
- No files are deleted; new folders are created only within the target directory.
Metadata
Frequently Asked Questions
What is 文件整理?
文件整理 - 桌面和下载文件夹一键自动归类:图片/文档/压缩包/视频/音频/代码,生成整理报告. It is an AI Agent Skill for Claude Code / OpenClaw, with 62 downloads so far.
How do I install 文件整理?
Run "/install laosi-file-organizer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is 文件整理 free?
Yes, 文件整理 is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does 文件整理 support?
文件整理 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created 文件整理?
It is built and maintained by 534422530 (@534422530); the current version is v1.1.0.
More Skills