file-organization-expert

File Organization Expert: Helps organize desktop and folders with features for intelligent classification (by file type), bulk renaming (sequence/date/custom patterns), file deduplication (hash-based), junk cleanup, date-based archiving, intelligent search and packaging/compression. Use when users ask for “organize folders”, “clean desktop”, “batch rename”, “remove duplicate files”, “file classification”, “tidy downloads”, or “add prefix to files”.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "file-organization-expert" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a919553d73efc287b7e1cf9298dbad3e5c42a53d8575a17357f52a6b3cfca9b4. Verify the upstream source and version against https://skillhub.cn/skills/user_92725383/file-organization-expert before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

File Organization Expert: Helps organize desktop and folders with features for intelligent classification (by file type), bulk renaming (sequence/date/custom patterns), file deduplication (hash-based), junk cleanup, date-based archiving, intelligent search and packaging/compression. Use when users ask for “organize folders”, “clean desktop”, “batch rename”, “remove duplicate files”, “file classification”, “tidy downloads”, or “add prefix to files”.

0 Downloads

Introduction source: third_party · user_92725383 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
```
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: "file-organization-expert"
description: "文件整理与归档专家 - 让电脑桌面和文件夹井然有序。支持智能分类(按文件类型自动归类)、批量重命名(序号/日期/自定义模式)、文件去重(哈希值精准去重)、垃圾清理、日期归档、智能搜索、打包压缩。当用户提到\"整理文件夹\"、\"清理桌面\"、\"批量重命名\"、\"删除重复文件\"、\"文件归类\"、\"整理下载文件夹\"、\"给文件加前缀\"等需求时,请使用此技能。"

文件整理与归档专家 - 技能设计文档

1. 目录结构

file-organizer-expert/
├── SKILL.md                      # 技能入口文档
├── pyproject.toml                # 项目配置
├── src/
│   ├── __init__.py
│   ├── cli.py                    # CLI 入口(argparse 主程序)
│   ├── core/
│   │   ├── __init__.py
│   │   ├── scanner.py            # 目录扫描与文件发现
│   │   ├── classifier.py         # 文件分类引擎
│   │   ├── renamer.py            # 批量重命名引擎
│   │   ├── archiver.py           # 日期归档引擎
│   │   ├── deduplicator.py       # 文件去重引擎
│   │   ├── cleaner.py            # 临时文件清理器
│   │   ├── packer.py             # 批量压缩器
│   │   └── preview.py            # 预览/dry-run 管理器
│   ├── commands/
│   │   ├── __init__.py
│   │   ├── cmd_classify.py       # classify 子命令
│   │   ├── cmd_rename.py         # rename 子命令
│   │   ├── cmd_archive.py        # archive 子命令
│   │   ├── cmd_deduplicate.py    # deduplicate 子命令
│   │   ├── cmd_cleanup.py        # cleanup 子命令
│   │   ├── cmd_compress.py       # compress 子命令
│   │   ├── cmd_preview.py        # preview 子命令
│   │   └── cmd_batch.py          # batch 子命令
│   └── utils/
│       ├── __init__.py
│       ├── file_hash.py          # 文件哈希计算(MD5/SHA256)
│       ├── patterns.py           # 文件类型映射表
│       ├── validators.py         # 路径与参数校验
│       ├── logger.py             # 日志与报告输出
│       └── progress.py           # 进度条显示
├── tests/
│   ├── __init__.py
│   ├── test_classify.py
│   ├── test_rename.py
│   ├── test_archive.py
│   ├── test_deduplicate.py
│   └── test_cli.py
└── docs/
    ├── quickstart.md             # 快速入门
    ├── examples.md               # 使用示例
    └── configuration.md          # 自定义配置说明

2. 功能优先级与特性矩阵

功能 优先级 用户需求场景 核心算法
classify P0 下载目录杂乱,按扩展名自动归类 扩展名→文件夹映射
rename P0 照片/文档批量规范命名 序号递增、日期提取、正则替换
archive P1 按年月整理历史文件 文件mtime解析→目录树构建
deduplicate P1 多份相同文件占用空间 分块哈希比对(先大小→后MD5→SHA256确认)
cleanup P2 清理 .tmp/.DS_Store/空文件 模式匹配+空文件检测
compress P2 批量打包发送给同事 zipfile/tarfile 打包
preview P0 所有操作的 dry-run 模式 操作日志记录,不执行实际变更
batch P2 同时处理多个项目目录 并行/串行执行调度

3. 依赖策略

核心原则:纯 Python 标准库,零外部依赖

模块 使用的标准库
文件系统 os, pathlib, shutil, stat
文件哈希 hashlib
时间处理 datetime, time
压缩 zipfile, tarfile
CLI argparse
并发 concurrent.futures
序列化 json
子进程 subprocess
测试 pytest(仅开发依赖)

4. CLI 架构设计

4.1 主命令结构

file-org [全局选项] <子命令> [子命令参数]

4.2 全局选项

选项 简写 默认值 说明
--directory -d 当前目录 目标目录
--verbose -v False 显示详细输出
--quiet -q False 静默模式
--log-file -l 无 输出日志文件路径
--preview -p False 预览模式(不执行实际操作)

4.3 子命令详解


classify - 按文件类型自动分类

file-org classify [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 要整理的目录
--rules string builtin 分类规则:builtin/custom/路径到JSON规则文件
--ignore-hidden flag True 忽略隐藏文件
--move-vs-copy choice move 操作方式:move/copy
--overwrite flag False 同名文件是否覆盖

内置分类规则示例:

{
  "images": [".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp"],
  "documents": [".pdf", ".doc", ".docx", ".txt", ".md", ".xlsx", ".pptx"],
  "videos": [".mp4", ".avi", ".mkv", ".mov", ".wmv"],
  "audio": [".mp3", ".wav", ".flac", ".aac", ".ogg"],
  "archives": [".zip", ".tar", ".gz", ".rar", ".7z"],
  "code": [".py", ".js", ".java", ".cpp", ".go", ".html", ".css"],
  "executables": [".exe", ".msi", ".app", ".dmg"],
  "other": []
}

rename - 批量重命名

file-org rename [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 目标目录
--mode choice required 重命名模式:sequence/date/pattern/lower/upper/title
--prefix string 空 文件名前缀(sequence/date模式)
--start int 1 起始序号(sequence模式)
--padding int 3 序号位数,如001、002(sequence模式)
--date-format string %Y%m%d 日期格式字符串(date模式)
--pattern string 无 搜索模式(pattern模式,支持正则)
--replacement string 空 替换文本(pattern模式)
--filter string * 文件过滤通配符,如 *.jpg
--recursive flag False 递归子目录

archive - 按日期归档

file-org archive [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 目标目录
--strategy choice modified 日期基准:modified/created/accessed
--structure choice year/month 目录结构:year/year-month/year/month/month-year
--flat flag False 扁平化命名(不创建子目录,改为前缀)
--separator string - 日期与原名间的分隔符(flat模式)
--filter string * 文件过滤通配符

归档结构示例:

year/month:  2024/01/document.pdf
year-month:  2024-01/document.pdf
year:        2024/document.pdf
month-year:  01-2024/document.pdf

deduplicate - 文件去重

file-org deduplicate [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 目标目录
--action choice report 操作:report/delete/move/hardlink/symlink
--target-dir string 无 重复文件移动目标目录(action=move)
--keep choice newest 保留策略:newest/oldest/longest-name/shortest-path
--hash-algo choice sha256 哈希算法:md5/sha1/sha256
--recursive flag True 递归扫描
--cross-directory flag False 跨目录去重(batch模式相关)

性能优化策略:

  1. 先按文件大小分组(不同大小必然不同)
  2. 同大小文件读取前4KB计算部分哈希
  3. 完全相同的部分哈希再计算完整文件哈希
  4. 最终确认重复组

cleanup - 清理临时文件

file-org cleanup [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 目标目录
--temp-extensions string builtin 临时文件扩展名列表:builtin 或逗号分隔
--include-empty flag True 包含空文件检测
--include-dsstore flag True 包含 .DS_Store 文件
--include-thumbsdb flag True 包含 Thumbs.db 文件
--recursive flag True 递归处理
--dry-run-only flag False 仅报告,不删除

内置临时扩展名: .tmp, .temp, .bak, .swp, .swo, ~, .DS_Store, Thumbs.db, .log


compress - 批量压缩打包

file-org compress [目录] [选项]
参数 类型 默认值 说明
directory positional 当前目录 目标目录
--format choice zip 压缩格式:zip/tar.gz/tar.bz2/tar.xz
--output string 目录名 输出文件名(不含后缀)
--output-dir string 父目录 输出文件存放目录
--filter string * 文件过滤通配符
--recursive flag True 包含子目录
--password string 无 ZIP加密密码
--delete-original flag False 压缩成功后删除原文件

preview - 预览模式(dry-run)

file-org preview <子命令> [子命令参数]

此命令包装其他子命令,模拟执行并输出预期变更:

参数 类型 默认值 说明
wrapped_command positional required 要预览的子命令名
wrapped_args variadic 无 传递给子命令的参数

预览输出示例:

[PREVIEW] 如果执行 classify:
  /Downloads/report.pdf    → /Downloads/documents/report.pdf
  /Downloads/photo.jpg     → /Downloads/images/photo.jpg
  /Downloads/video.mp4     → /Downloads/videos/video.mp4
────────────────────────────────────────────
  预计移动: 3 个文件
  预计创建: 3 个文件夹

batch - 批量处理多个目录

file-org batch [选项]
参数 类型 默认值 说明
--directories string required 目录列表(逗号分隔或JSON数组)
--command string required 对每个目录执行的子命令
--command-args string 无 传递给子命令的额外参数(JSON格式)
--parallel flag False 是否并行处理
--workers int 4 并行工作进程数
--stop-on-error flag False 遇到错误是否停止
--report-output string 无 批量处理报告输出路径

5. 核心模块说明

5.1 src/cli.py - CLI 入口

def main():
    parser = argparse.ArgumentParser(
        prog='file-org',
        description='文件整理与归档专家 - 让办公桌面井井有条'
    )

    # 全局参数
    parser.add_argument('-d', '--directory', default='.')
    parser.add_argument('-v', '--verbose', action='store_true')
    parser.add_argument('-q', '--quiet', action='store_true')
    parser.add_argument('-l', '--log-file')
    parser.add_argument('-p', '--preview', action='store_true')

    subparsers = parser.add_subparsers(dest='command', required=True)

    # 注册各子命令
    register_classify(subparsers)
    register_rename(subparsers)
    register_archive(subparsers)
    register_deduplicate(subparsers)
    register_cleanup(subparsers)
    register_compress(subparsers)
    register_preview(subparsers)
    register_batch(subparsers)

    args = parser.parse_args()
    args.func(args)

5.2 子命令模块模式

每个 commands/cmd_xxx.py 遵循统一接口:

def register_parser(subparsers):
    """注册子命令解析器"""
    parser = subparsers.add_parser('classify', help='按文件类型自动分类')
    parser.add_argument('directory', nargs='?', default='.')
    parser.add_argument('--rules', default='builtin')
    # ...
    parser.set_defaults(func=run)

def run(args):
    """执行子命令逻辑"""
    # 1. 验证输入
    # 2. 创建预览管理器(如果 args.preview)
    # 3. 调用核心引擎
    # 4. 输出报告
    pass

5.3 core/preview.py - 预览管理器

class PreviewManager:
    """干运行管理器 - 记录操作但不实际执行"""

    def __init__(self, enabled=False):
        self.enabled = enabled
        self.operations = []  # 记录的操作列表

    def record(self, op_type, source, destination=None, details=None):
        """记录一个操作"""
        if self.enabled:
            self.operations.append({
                'type': op_type,
                'source': str(source),
                'destination': str(destination) if destination else None,
                'details': details
            })
        return not self.enabled  # 非预览模式返回True执行实际操作

    def should_execute(self, operation_func, *args, **kwargs):
        """决定是否执行实际操作"""
        if self.enabled:
            self.record(operation_func.__name__, *args, **kwargs)
            return False
        operation_func(*args, **kwargs)
        return True

    def report(self):
        """输出预览报告"""
        # 格式化输出所有记录的操作
        pass

5.4 utils/file_hash.py - 文件哈希

class FileHasher:
    """分块文件哈希 - 避免大文件内存溢出"""

    def __init__(self, algorithm='sha256', chunk_size=8192):
        self.algorithm = algorithm
        self.chunk_size = chunk_size

    def hash_file(self, filepath):
        """计算文件完整哈希"""
        hasher = hashlib.new(self.algorithm)
        with open(filepath, 'rb') as f:
            while chunk := f.read(self.chunk_size):
                hasher.update(chunk)
        return hasher.hexdigest()

    def hash_partial(self, filepath, offset=0, size=4096):
        """计算文件部分哈希(用于快速初筛)"""
        hasher = hashlib.new(self.algorithm)
        with open(filepath, 'rb') as f:
            f.seek(offset)
            data = f.read(size)
            hasher.update(data)
        return hasher.hexdigest()

5.5 utils/progress.py - 进度显示

class SimpleProgress:
    """纯标准库进度条 - 当tqdm不可用时的降级方案"""

    def __init__(self, total, desc=''):
        self.total = total
        self.current = 0
        self.desc = desc

    def update(self, n=1):
        self.current += n
        pct = self.current / self.total * 100
        bar_len = 30
        filled = int(bar_len * self.current // self.total)
        bar = '█' * filled + '░' * (bar_len - filled)
        print(f'\r{self.desc}: [{bar}] {self.current}/{self.total} ({pct:.1f}%)', end='')

    def close(self):
        print()  # 换行

6. 非技术用户设计考量

6.1 安全机制

功能 实现方式
默认预览 所有写操作默认先进入预览模式,需确认才执行
撤销支持 记录操作日志到 ~/.file-org/undo_{timestamp}.json
冲突处理 同名文件不覆盖,自动添加 (1), (2) 后缀
权限检查 操作前验证读写权限,拒绝无权限操作

6.2 输出友好性

# 成功输出
✅ 分类完成!
  📁 创建文件夹: 3 个 (images, documents, videos)
  📄 移动文件: 15 个
  ⏱️  耗时: 0.3秒

# 预览输出
⚠️ 预览模式 - 以下操作尚未执行:
  /Downloads/report.pdf    → /Downloads/documents/report.pdf
  /Downloads/photo.jpg     → /Downloads/images/photo.jpg

💡 确认执行?运行: file-org classify /Downloads --confirm

# 错误输出
❌ 错误: 目录 /path/not/exists 不存在
💡 请检查路径是否正确

6.3 交互式确认

def ask_confirmation(ops_count):
    """操作前确认"""
    print(f"即将执行 {ops_count} 个文件操作,是否继续?")
    print("  [Y] 是  [N] 否  [D] 显示详情  [P] 导出预览到文件")
    while True:
        choice = input("> ").lower().strip()
        if choice in ('y', 'yes'):
            return True
        if choice in ('n', 'no'):
            return False
        if choice == 'd':
            show_detailed_preview()
        if choice == 'p':
            export_preview_to_file()

7. 扩展性设计

7.1 插件式分类规则

// ~/.file-org/rules/custom_rules.json
{
  "财务资料": [".xlsx", ".xls", ".csv"],
  "合同文档": [".pdf"],
  "设计素材": [".psd", ".ai", ".sketch"],
  "代码仓库": [".py", ".js", ".go"]
}

7.2 配置文件

# ~/.file-org/config.yaml
defaults:
  preview: true
  overwrite: false
  recursive: true

classify:
  rules: builtin
  ignore_hidden: true

rename:
  default_prefix: ""
  date_format: "%Y%m%d"

archive:
  structure: year/month
  strategy: modified

8. 测试策略

测试类型 覆盖范围
单元测试 单个引擎函数的输入输出
集成测试 CLI 子命令端到端执行
mocks 文件系统操作(使用tempfile/monkeypatch)
边界情况 空目录、权限拒绝、特殊字符文件名
性能测试 大目录(10000+文件)处理时间

9. 安装方式

# pip 安装(未来发布到PyPI后)
pip install file-org-expert

# 本地开发
pip install -e .

# 直接运行(无需安装)
python -m src.cli classify /path/to/dir

10. 示例命令

# 整理下载目录(预览模式)
file-org classify ~/Downloads -p

# 整理并确认执行
file-org classify ~/Downloads --rules builtin --move-vs-copy move

# 批量重命名照片
file-org rename ~/Photos --mode date --date-format "%Y%m%d" --prefix "trip_" --filter "*.jpg"

# 按日期归档
file-org archive ~/Projects --structure year-month

# 查找重复文件
file-org deduplicate ~/Documents --action report --recursive

# 清理临时文件
file-org cleanup ~/Projects --recursive

# 预览重命名效果
file-org preview rename ~/Downloads --mode sequence --start 1 --prefix "doc_"

# 批量处理多个目录
file-org batch --directories "~/Downloads,~/Desktop,~/Documents" --command classify

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 解决用户高频刚需:文件整理、批量重命名、去重等是日常办公核心痛点
  • 功能覆盖全面:涵盖分类、重命名、归档、去重、清理、压缩等完整工作流
  • 纯Python标准库实现,零外部依赖,部署简单
Trigger Precision85/100

Areas to improve

  • pattern模式触发描述略简略 Reported severity: Minor

    rename子命令的pattern模式缺少具体正则表达式示例

    Recommendation: 补充pattern模式的正则表达式使用示例,如'--pattern "IMG_[0-9]+" --replacement "photo_"'

Highlights

  • 触发词覆盖全面:包含'整理文件夹'、'清理桌面'、'批量重命名'等用户常用表达
  • 边界清晰:各子命令功能划分明确,不易与其他技能混淆
Structure and Standards90/100

Areas to improve

  • 文档长度超过500行 Reported severity: Minor

    SKILL.md文档约1200行,超出建议长度

    Recommendation: 考虑将详细实现细节移至docs/目录下的独立文档,SKILL.md保留核心功能说明

Highlights

  • Phase/步骤清晰:各子命令功能、参数、示例完整
  • 有出口条件:每个操作都有明确的完成状态和报告输出
  • 包含端到端示例:提供了完整的命令行使用示例
  • frontmatter完整:name和description均正确配置
Execution Reliability88/100

Areas to improve

  • 权限错误处理未详细说明 Reported severity: Minor

    未明确说明在遇到无权限文件时的具体处理策略

    Recommendation: 补充权限错误的处理机制,如跳过无权限文件并记录到日志

Highlights

  • 工具来源明确:全部使用Python标准库,无第三方依赖风险
  • 参数正确:各子命令参数设计合理,类型明确
  • 覆盖主要异常:有预览模式、冲突处理、撤销支持等安全机制
  • 不可逆操作有确认机制:删除、移动等操作都有预览和确认流程
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.