重复文档清理

SKILL效率
效率 未标注权限 许可证不明确
安装这个技能

重复文档清理

一句话选型结论

按资料字段整理

重复文档清理是效率类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类效率 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_08f07800/zyn
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

效率
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_08f07800仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791719015
正文体量14.9 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
整理待办与日程

把零散任务收进清单,排出优先级。

批量处理重复任务

把固定动作做成模板,重复执行。

把流程写成清单

把口头流程整理成可复用的步骤。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在效率场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
重复文档清理当前 未标注权限 未标注 未标注 未标注 有
Nano PDF 文档 联网访问 ClawHub 市场 424.9 万 OpenClaw 有
自动更新程序 浏览器控制 ClawHub 市场 296.4 万 OpenClaw 有
Gemini 助手 联网访问 ClawHub 市场 254.7 万 OpenClaw 有
word DOCX 文档 联网访问 ClawHub 市场 239.6 万 OpenClaw 有
Excel XLSX 前端 联网访问 ClawHub 市场 227.0 万 OpenClaw 有

SKILL.md 全文

14.9 KB
模型实际读到的说明书原文,来自技能仓库

!/usr/bin/env python3

-- coding: utf-8 --

Windows UTF-8 输出兼容

import sys
import io
if sys.platform == 'win32':
try:
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
except Exception:
pass

"""
文档重复清理工具 (Document Duplicate Cleaner)
基于 SHA-256 内容哈希检测并清理重复文档
支持 .pdf, .docx, .xlsx, .pptx, .txt, .md, .csv, .json, .xml 等格式
"""

import os
import sys
import hashlib
import argparse
import re
from pathlib import Path
from collections import defaultdict
from datetime import datetime

支持的文件扩展名

SUPPORTED_EXTENSIONS = {
'.pdf', '.docx', '.doc', '.xlsx', '.xls', '.pptx', '.ppt',
'.txt', '.md', '.csv', '.json', '.xml', '.html', '.htm',
'.rtf', '.odt', '.ods', '.odp', '.eml', '.msg', '.rtf'
}

排除的目录

EXCLUDED_DIRS = {'.git', '.svn', '.hg', 'pycache', 'node_modules',
'.DS_Store', 'Thumbs.db', '.cache'}

def calculate_file_hash(filepath: Path, chunk_size: int = 65536) -> str:
"""计算文件内容的 SHA-256 哈希值"""
sha256 = hashlib.sha256()
try:
with open(filepath, 'rb') as f:
while chunk := f.read(chunk_size):
sha256.update(chunk)
return sha256.hexdigest()
except (IOError, OSError) as e:
print(f" [警告] 无法读取文件 {filepath}: {e}")
return ""

def scan_directory(root_path: Path, recursive: bool = True,
exclude_patterns: list = None,
file_extensions: set = None) -> dict:
"""
扫描目录中的所有支持的文件
返回 {文件路径: (哈希值, 文件大小, 修改时间)}
"""
if file_extensions is None:
file_extensions = SUPPORTED_EXTENSIONS

exclude_patterns = exclude_patterns or []
files_info = {}

# 将根目录转换为字符串用于比较
root_str = str(root_path.resolve())

for dirpath, dirnames, filenames in os.walk(root_path):
    # 过滤排除的目录(原地修改,防止 os.walk 进入)
    dirnames[:] = [d for d in dirnames if d not in EXCLUDED_DIRS]

    # 应用用户指定的排除模式
    for pattern in exclude_patterns:
        dirnames[:] = [d for d in dirnames if not re.search(pattern, d)]

    for filename in filenames:
        filepath = Path(dirpath) / filename

        # 检查扩展名
        ext = filepath.suffix.lower()
        if ext not in file_extensions:
            continue

        # 应用文件排除模式
        skip = False
        for pattern in exclude_patterns:
            if re.search(pattern, filename):
                skip = True
                break
        if skip:
            continue

        # 计算哈希
        file_hash = calculate_file_hash(filepath)
        if not file_hash:
            continue

        # 获取文件信息
        stat = filepath.stat()
        files_info[str(filepath)] = {
            'hash': file_hash,
            'size': stat.st_size,
            'mtime': stat.st_mtime,
            'name': filepath.name,
            'relative_path': str(filepath.relative_to(root_path))
        }

return files_info

def find_duplicates(files_info: dict) -> dict:
"""基于哈希值找出重复文件分组"""
hash_groups = defaultdict(list)

for filepath, info in files_info.items():
    hash_groups[info['hash']].append({
        'path': filepath,
        'size': info['size'],
        'mtime': info['mtime'],
        'name': info['name'],
        'relative_path': info['relative_path']
    })

# 只返回有重复的组(至少2个文件)
duplicates = {h: group for h, group in hash_groups.items() if len(group) > 1}
return duplicates

def format_size(size_bytes: int) -> str:
"""格式化文件大小"""
for unit in ['B', 'KB', 'MB', 'GB']:
if size_bytes < 1024:
return f"{size_bytes:.1f} {unit}"
size_bytes /= 1024
return f"{size_bytes:.1f} TB"

def format_time(timestamp: float) -> str:
"""格式化时间戳"""
return datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')

def print_duplicate_report(duplicates: dict, files_info: dict, root_path: Path):
"""打印重复文件报告"""
if not duplicates:
print("\n✅ 未发现重复文件!")
return

total_groups = len(duplicates)
total_duplicates = sum(len(group) - 1 for group in duplicates.values())
total_wasted = sum(
    group[0][&#x27;size&#x27;] * (len(group) - 1)
    for group in duplicates.values()
)

print(f&quot;\n{&#x27;=&#x27;*80}&quot;)
print(f&quot;  📋 重复文件扫描报告&quot;)
print(f&quot;{&#x27;=&#x27;*80}&quot;)
print(f&quot;  发现 {total_groups} 组重复文件,共 {total_duplicates} 个重复文件&quot;)
print(f&quot;  可节省空间: {format_size(total_wasted)}&quot;)
print(f&quot;{&#x27;=&#x27;*80}\n&quot;)

for i, (file_hash, group) in enumerate(duplicates.items(), 1):
    # 按修改时间排序,最早的是原始文件
    group.sort(key=lambda x: x[&#x27;mtime&#x27;])
    original = group[0]
    dupes = group[1:]

    print(f&quot;\n{&#x27;─&#x27;*80}&quot;)
    print(f&quot;  📁 分组 {i} | 哈希前16位: {file_hash[:16]}... | 文档数: {len(group)}&quot;)
    print(f&quot;{&#x27;─&#x27;*80}&quot;)
    print(f&quot;  📄 文件大小: {format_size(original[&#x27;size&#x27;])}&quot;)
    print()

    # 显示原始文件
    print(f&quot;  ✅ [原始] {original[&#x27;relative_path&#x27;]}&quot;)
    print(f&quot;      修改时间: {format_time(original[&#x27;mtime&#x27;])}&quot;)

    # 尝试预览内容
    preview = get_file_preview(Path(original[&#x27;path&#x27;]))
    if preview:
        print(f&quot;      预览: {preview[:200]}&quot;)

    # 显示重复文件
    for dup in dupes:
        print(f&quot;\n  ❌ [重复] {dup[&#x27;relative_path&#x27;]}&quot;)
        print(f&quot;          修改时间: {format_time(dup[&#x27;mtime&#x27;])}&quot;)

def get_file_preview(filepath: Path, max_chars: int = 200) -> str:
"""获取文件文本预览(仅适用于文本格式)"""
text_extensions = {'.txt', '.md', '.csv', '.json', '.xml', '.html', '.htm', '.eml'}
ext = filepath.suffix.lower()

if ext not in text_extensions:
    return None

try:
    # 尝试多种编码
    for enc in [&#x27;utf-8&#x27;, &#x27;gbk&#x27;, &#x27;gb2312&#x27;, &#x27;latin-1&#x27;]:
        try:
            with open(filepath, &#x27;r&#x27;, encoding=enc) as f:
                content = f.read(max_chars)
                # 清理不可见字符
                content = re.sub(r&#x27;[\x00-\x08\x0b-\x0c\x0e-\x1f]&#x27;, &#x27;&#x27;, content)
                return content.strip()
        except (UnicodeDecodeError, IOError):
            continue
except Exception:
    pass
return None

def interactive_clean(duplicates: dict, dry_run: bool = True):
"""交互式清理重复文件"""
if not duplicates:
return 0

deleted_count = 0
deleted_size = 0
to_delete = []

print(f&quot;\n{&#x27;=&#x27;*80}&quot;)
print(f&quot;  🗑️  清理模式: {&#x27;DRY-RUN(仅报告,不删除)&#x27; if dry_run else &#x27;实际删除&#x27;}&quot;)
print(f&quot;{&#x27;=&#x27;*80}\n&quot;)

all_groups = list(duplicates.items())

for i, (file_hash, group) in enumerate(all_groups, 1):
    group.sort(key=lambda x: x[&#x27;mtime&#x27;])
    original = group[0]
    dupes = group[1:]

    print(f&quot;\n{&#x27;─&#x27;*80}&quot;)
    print(f&quot;  分组 {i}/{len(all_groups)} | 哈希: {file_hash[:16]}...&quot;)
    print(f&quot;{&#x27;─&#x27;*80}&quot;)
    print(f&quot;  保留: {original[&#x27;relative_path&#x27;]}&quot;)
    print(f&quot;  重复文件列表:&quot;)
    for j, dup in enumerate(dupes, 1):
        print(f&quot;    {j}. {dup[&#x27;relative_path&#x27;]} ({format_size(dup[&#x27;size&#x27;])})&quot;)

    if dry_run:
        print(f&quot;\n  [DRY-RUN] 将删除 {len(dupes)} 个文件,节省 {format_size(original[&#x27;size&#x27;] * len(dupes))}&quot;)
        for dup in dupes:
            to_delete.append((dup[&#x27;path&#x27;], dup[&#x27;size&#x27;]))
    else:
        print(f&quot;\n  选择操作:&quot;)
        print(f&quot;    1. 保留所有(不删除)&quot;)
        print(f&quot;    2. 删除所有重复文件&quot;)
        print(f&quot;    3. 选择性删除&quot;)

        choice = input(f&quot;  请输入选择 (1/2/3) [默认 1]: &quot;).strip() or &quot;1&quot;

        if choice == &quot;2&quot;:
            for dup in dupes:
                to_delete.append((dup[&#x27;path&#x27;], dup[&#x27;size&#x27;]))
        elif choice == &quot;3&quot;:
            for j, dup in enumerate(dupes, 1):
                print(f&quot;    {j}. {dup[&#x27;relative_path&#x27;]}&quot;)
            sel = input(f&quot;  输入要删除的编号,用逗号分隔 [如 1,3]: &quot;).strip()
            if sel:
                try:
                    indices = [int(x.strip()) - 1 for x in sel.split(&#x27;,&#x27;)]
                    for idx in indices:
                        if 0 &lt;= idx &lt; len(dupes):
                            to_delete.append((dupes[idx][&#x27;path&#x27;], dupes[idx][&#x27;size&#x27;]))
                except ValueError:
                    print(&quot;  [跳过] 无效的输入&quot;)

# 执行删除
if to_delete:
    to_delete = list(set(to_delete))  # 去重
    print(f&quot;\n{&#x27;=&#x27;*80}&quot;)
    print(f&quot;  ⚠️  即将 {&#x27;模拟&#x27; if dry_run else &#x27;删除&#x27;} {len(to_delete)} 个文件&quot;)
    print(f&quot;{&#x27;=&#x27;*80}&quot;)

    for path, size in to_delete:
        print(f&quot;  {&#x27;将删除&#x27; if dry_run else &#x27;删除&#x27;}: {path}&quot;)

    if not dry_run:
        confirm = input(f&quot;\n  ⚠️  确认删除 {len(to_delete)} 个文件?(y/N): &quot;).strip()
        if confirm.lower() != &#x27;y&#x27;:
            print(&quot;  [取消] 删除操作已取消&quot;)
            return 0

    if dry_run:
        print(f&quot;\n  [DRY-RUN] 模拟删除完成,共将删除 {len(to_delete)} 个文件&quot;)
        print(f&quot;            将节省空间: {format_size(sum(s for _, s in to_delete))}&quot;)
    else:
        for path, size in to_delete:
            try:
                os.remove(path)
                deleted_count += 1
                deleted_size += size
                print(f&quot;  ✅ 已删除: {path}&quot;)
            except OSError as e:
                print(f&quot;  ❌ 删除失败: {path} - {e}&quot;)

        print(f&quot;\n  📊 清理完成!已删除 {deleted_count} 个文件,节省 {format_size(deleted_size)}&quot;)

return deleted_count

def main():
parser = argparse.ArgumentParser(
description='文档重复清理工具 - 基于 SHA-256 检测并清理重复文档',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
使用示例:
python duplicate_cleaner.py C:\Documents
python duplicate_cleaner.py . -r # 递归扫描当前目录
python duplicate_cleaner.py . --dry-run # 仅报告,不删除
python duplicate_cleaner.py . -e "temp|backup" # 排除匹配的文件/目录
python duplicate_cleaner.py . --delete # 实际删除(默认 dry-run)
"""
)

parser.add_argument(&#x27;path&#x27;, nargs=&#x27;?&#x27;, default=&#x27;.&#x27;,
                    help=&#x27;要扫描的目录路径(默认: 当前目录)&#x27;)
parser.add_argument(&#x27;-r&#x27;, &#x27;--recursive&#x27;, action=&#x27;store_true&#x27;, default=True,
                    help=&#x27;递归扫描子目录(默认: 开启)&#x27;)
parser.add_argument(&#x27;--no-recursive&#x27;, action=&#x27;store_true&#x27;,
                    help=&#x27;不扫描子目录&#x27;)
parser.add_argument(&#x27;-e&#x27;, &#x27;--exclude&#x27;, action=&#x27;append&#x27;,
                    help=&#x27;排除匹配的文件/目录(支持正则,可用多次)&#x27;)
parser.add_argument(&#x27;--dry-run&#x27;, action=&#x27;store_true&#x27;, default=True,
                    dest=&#x27;dry_run&#x27;,
                    help=&#x27;仅报告,不删除(默认行为)&#x27;)
parser.add_argument(&#x27;--delete&#x27;, action=&#x27;store_false&#x27;, default=True,
                    dest=&#x27;dry_run&#x27;,
                    help=&#x27;实际删除重复文件(需确认)&#x27;)
parser.add_argument(&#x27;-o&#x27;, &#x27;--output&#x27;, metavar=&#x27;FILE&#x27;,
                    help=&#x27;将报告保存到指定文件&#x27;)
parser.add_argument(&#x27;-q&#x27;, &#x27;--quiet&#x27;, action=&#x27;store_true&#x27;,
                    help=&#x27;静默模式,仅输出关键信息&#x27;)
parser.add_argument(&#x27;--ext&#x27;, metavar=&#x27;EXT&#x27;, action=&#x27;append&#x27;,
                    help=&#x27;指定额外的文件扩展名(如 .pdf)&#x27;)

args = parser.parse_args()

# 处理路径
scan_path = Path(args.path).resolve()
if not scan_path.exists():
    print(f&quot;❌ 错误: 路径不存在: {scan_path}&quot;, file=sys.stderr)
    sys.exit(1)
if not scan_path.is_dir():
    print(f&quot;❌ 错误: 路径不是目录: {scan_path}&quot;, file=sys.stderr)
    sys.exit(1)

# 配置
recursive = not args.no_recursive
exclude_patterns = args.exclude or []

# 添加扩展名
exts = SUPPORTED_EXTENSIONS.copy()
if args.ext:
    for e in args.ext:
        if not e.startswith(&#x27;.&#x27;):
            e = &#x27;.&#x27; + e
        exts.add(e.lower())

print(f&quot;\n🔍 正在扫描: {scan_path}&quot;)
if recursive:
    print(f&quot;   模式: 递归扫描&quot;)
else:
    print(f&quot;   模式: 仅当前目录&quot;)
if exclude_patterns:
    print(f&quot;   排除: {&#x27;, &#x27;.join(exclude_patterns)}&quot;)
print(f&quot;   支持格式: {&#x27;, &#x27;.join(sorted(exts))}&quot;)

# 扫描
files_info = scan_directory(scan_path, recursive, exclude_patterns, exts)
print(f&quot;\n📄 共发现 {len(files_info)} 个文件&quot;)

if not files_info:
    print(&quot;❌ 未找到任何支持的文件格式&quot;)
    sys.exit(0)

# 找重复
duplicates = find_duplicates(files_info)

# 生成报告
import io
from contextlib import redirect_stdout

if args.output:
    # 保存到文件
    buffer = io.StringIO()
    with redirect_stdout(buffer):
        print_duplicate_report(duplicates, files_info, scan_path)
        if duplicates:
            deleted = interactive_clean(duplicates, args.dry_run)
    content = buffer.getvalue()
    with open(args.output, &#x27;w&#x27;, encoding=&#x27;utf-8&#x27;) as f:
        f.write(content)
    print(f&quot;\n✅ 报告已保存到: {args.output}&quot;)
else:
    # 打印到控制台
    if not args.quiet:
        print_duplicate_report(duplicates, files_info, scan_path)

    if duplicates:
        deleted = interactive_clean(duplicates, args.dry_run)
        if args.dry_run:
            print(f&quot;\n💡 提示: 以上为 Dry-Run 结果,如需实际删除,请使用 --delete 参数&quot;)
    else:
        print(&quot;\n✅ 未发现重复文件&quot;)

return 0

if name == 'main':
try:
sys.exit(main())
except KeyboardInterrupt:
print("\n\n[中断] 操作已取消")
sys.exit(130)

常见问题

5 问
答案由本站依据条目字段整理
重复文档清理怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_08f07800/zyn。安装方式为未标注。装完刷新技能列表或重开客户端。

重复文档清理支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

重复文档清理权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

重复文档清理收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

重复文档清理用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。