Install
openclaw skills install document-organizer支持批量将旧版 Office 文档(.doc/.xls)高质量转换为 Markdown 并保持目录结构与格式完整。
openclaw skills install document-organizer专业的文档批量处理技能,支持旧版 Office 文档(.doc/.xls)高质量转换为 Markdown,保持格式结构完整。
.doc → .md(LibreOffice 直接转换).docx → .md(LibreOffice 直接转换).xls → .xlsx → .md(保留表格结构).ppt → .pptx → .md(可选支持).xlsx/.pptx → .md(MarkItDown 直接处理)# 安装 LibreOffice(系统级)
# 下载: https://zh-cn.libreoffice.org/
# 安装 Python 依赖
pip install markitdown[docx,xlsx]
# 交互模式(推荐)
npx skills run document-organizer
# 命令行参数
npx skills run document-organizer --source "源目录" --output "输出目录" --type doc,xls
首次运行会检测 LibreOffice 路径,默认:
D:\Program Files\LibreOffice\program\soffice.exe/usr/bin/soffice/Applications/LibreOffice.app/Contents/MacOS/soffice| 源格式 | 转换流程 | 输出格式 | 质量 |
|---|---|---|---|
.doc | LibreOffice → Markdown | .md | ✅ 完美 |
.docx | LibreOffice → Markdown | .md | ✅ 完美 |
.xls | LibreOffice → .xlsx → MarkItDown → .md | .md | ✅ 完美 |
.xlsx | MarkItDown → .md | .md | ✅ 完美 |
.ppt | LibreOffice → .pptx → MarkItDown → .md | .md | ✅ 良好 |
.pptx | MarkItDown → .md | .md | ✅ 良好 |
.pdf | MarkItDown → .md | .md | ✅ 优秀(文本+表格) |
方案一:分类批量(推荐)
批量转换所有 .doc 文件:
soffice --convert-to md *.doc
批量转换所有 .docx 文件:
soffice --convert-to md *.docx
批量转换所有 .xls 文件:
soffice --convert-to xlsx *.xls → markitdown *.xlsx
批量转换所有 .ppt 文件:
soffice --convert-to pptx *.ppt → markitdown *.pptx
方案二:递归处理
扫描目录树,按文件类型分组
分别批量转换每个子目录
保持完整目录结构输出
# 扫描源目录
npx skills run document-organizer --source "G:\历史文档" --output "d:\知识库"
输出结构:
知识库/
├── 项目A/
│ ├── 需求文档.md
│ └── 设计文档.md
└── 项目B/
└── 会议记录.md
npx skills run document-organizer --source "G:\docs" --output "d:\md" --filter .doc,.docx
npx skills run document-organizer --source "G:\pdfs" --type pdf --output "d:\pdf_md"
npx skills run document-organizer --scan-only "G:\docs"
# 输出: 文件统计,不执行转换
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
--source | string | 必需 | 源目录路径 |
--output | string | ./output | 输出目录 |
--type | string | doc,xls,docx,xlsx,ppt,pptx,pdf | 处理的文件类型(逗号分隔) |
--soffice-path | string | 自动检测 | LibreOffice soffice.exe 路径 |
--log-file | string | conversion.log | 日志文件路径 |
--dry-run | bool | false | 仅模拟,不实际转换 |
测试环境: i5 CPU, 16GB RAM, SSD
| 操作 | 数量 | 耗时 | 吞吐 |
|---|---|---|---|
| .doc → .md (LibreOffice) | 1,000 | ~30 秒 | 33 个/秒 |
| .xls → .xlsx (LibreOffice) | 2,000 | ~1.5 分钟 | 22 个/秒 |
| .xlsx → .md (MarkItDown) | 2,000 | ~2 分钟 | 17 个/秒 |
| .ppt → .pptx (LibreOffice) | 500 | ~30 秒 | 17 个/秒 |
| .pptx → .md (MarkItDown) | 500 | ~1 分钟 | 8 个/秒 |
| .pdf → .md (MarkItDown) | 500 | ~2 分钟 | 4 个/秒 |
| 总计 (3,000文件) | 3,000 | ~10-12 分钟 | - |
A: 确保安装并添加到 PATH,或通过 --soffice-path 指定:
npx skills run document-organizer --soffice-path "C:\Program Files\LibreOffice\program\soffice.exe"
A: 检查错误日志,常见原因:
~$ 开头)自动跳过A: 使用 --dry-run 参数:
npx skills run document-organizer --source "docs" --dry-run
# 输出: 将转换 X 个文件,Y 个目录,跳过 Z 个
A: 结合 --filter 和路径模式:
npx skills run document-organizer --source "docs" --filter "00_模板/*.doc"
┌─────────────────┐
│ 用户命令 │
│ npx skills ... │
└────────┬────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 文档整理技能 (Python) │
│ • 扫描目录树 │
│ • 按类型分组 (doc/xls/docx/xlsx) │
│ • 调用 LibreOffice 批量转换 │
│ • 调用 MarkItDown 结构化转换 │
│ • 保持目录结构 + 重命名 │
│ • 错误处理 + 日志记录 │
└─────────────────────────────────────────────┘
│
▼
┌─────────────────┐ ┌──────────────────┐
│ LibreOffice │ │ MarkItDown │
│ (格式转换) │ │ (结构化输出) │
└─────────────────┘ └──────────────────┘
│ │
└───────────┬───────────┘
▼
┌─────────────┐
│ .md 文件 │
│ (可搜索) │
└─────────────┘
| 工具 | 版本要求 | 用途 |
|---|---|---|
| LibreOffice | 7.0+ | .doc → .docx / .xls → .xlsx |
| Python | 3.10+ | 脚本运行 |
| markitdown | 0.1.5+ | .docx/.xlsx → .md |
| pywin32 | (可选) | Windows COM 自动化(备用) |
本技能包含以下脚本:
| 文件 | 说明 |
|---|---|
scripts/batch_convert.py | 主脚本 - 批量文档转换(支持 .doc/.xls/.docx/.xlsx/.ppt/.pptx/.pdf) |
strings 命令即可)v1.0.4 (2026-03-12)
v1.0.3 (2026-03-12)
--temp-dir 参数v1.0.2 (2026-03-11)
v1.0.0 (2026-03-11)
最后更新: 2026-03-12
适用平台: Windows/Linux/macOS (需 LibreOffice)
许可证: MIT