文件整理技能 (document-organizer)

👤 byteuser1977 📦 v1.0.4 ⭐ 4.5 ⬇️ 2.9K 下載
📄 辦公效率 免費

📖 技能介紹

文件整理技能 (document-organizer)

概述

專業的文件批次處理技能,支援舊版 Office 文件(.doc/.xls)高質量轉換為 Markdown,保持格式結構完整。


核心能力

✅ 格式轉換

  • Word 文件: .doc.md(LibreOffice 直接轉換)
  • Word 文件: .docx.md(LibreOffice 直接轉換)

    7w4.net小蔥技能。

  • Excel 表格: .xls.xlsx.md(保留表格結構)
  • PowerPoint: .ppt.pptx.md(可選支援)
  • 現代格式: .xlsx/.pptx.md(MarkItDown 直接處理)

✅ 批次處理

  • 支援按目錄批次轉換
  • 自動保持原目錄結構
  • 分類處理不同型別檔案
  • 錯誤自動記錄,不中斷流程

✅ 質量保證

  • 完美保留標題層級(H1-H6)
  • 表格結構完整(Markdown 表格)
  • 加粗/斜體樣式保留
  • 列表有序/無序完整
  • 中文無亂碼(UTF-8 編碼)

快速開始

1. 環境準備

# 安裝 LibreOffice(系統級)
# 下載: https://zh-cn.libreoffice.org/

# 安裝 Python 依賴
pip install markitdown[docx,xlsx]

2. 使用方法

# 互動模式(推薦)
npx skills run document-organizer

# 命令列引數
npx skills run document-organizer --source "源目錄" --output "輸出目錄" --type doc,xls

3. 配置

首次執行會檢測 LibreOffice 路徑,預設: - Windows: D:\Program Files\LibreOffice\program\soffice.exe - Linux: /usr/bin/soffice - macOS: /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

方案二:遞迴處理

掃描目錄樹,按檔案型別分組
分別批次轉換每個子目錄
保持完整目錄結構輸出

使用示例

示例 1: 轉換單個目錄

# 掃描源目錄
npx skills run document-organizer --source "G:\歷史文件" --output "d:\知識庫"

輸出結構:

知識庫/
├── 專案A/
│   ├── 需求文件.md
│   └── 設計文件.md
└── 專案B/
    └── 會議記錄.md

示例 2: 僅處理 Word 文件

npx skills run document-organizer --source "G:\docs" --output "d:\md" --filter .doc,.docx

示例 3: 處理 PDF 文件

npx skills run document-organizer --source "G:\pdfs" --type pdf --output "d:\pdf_md"

示例 4: 先掃描統計

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 分鐘 -

常見問題

Q: LibreOffice 找不到?

A: 確保安裝並新增到 PATH,或通過 --soffice-path 指定:

npx skills run document-organizer --soffice-path "C:\Program Files\LibreOffice\program\soffice.exe"

Q: 轉換失敗怎麼辦?

A: 檢查錯誤日誌,常見原因: - 原始檔損壞 - 臨時檔案(~$ 開頭)自動跳過 - 許可權不足(以管理員執行)

Q: 可以預覽而不轉換嗎?

A: 使用 --dry-run 引數:

npx skills run document-organizer --source "docs" --dry-run
# 輸出: 將轉換 X 個檔案,Y 個目錄,跳過 Z 個

Q: 如何只轉換特定子目錄?

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)

使用建議

✅ 推薦場景

  • 批次轉換舊版 Office 文件(.doc/.xls)
  • 構建可搜尋的知識庫
  • 文件數字化歸檔
  • 保留原始格式和結構

❌ 不推薦場景

  • 僅需提取純文本(用 strings 命令即可)
  • 掃描圖片型 PDF(需 OCR 專用工具)
  • 線上即時轉換(需啟動辦公軟體)

版本歷史

  • v1.0.4 (2026-03-12)
  • 修復:移除對不存在的外部 convert-markdown 目錄和指令碼的依賴
  • 修復:移除對特定路徑虛擬環境的依賴
  • 最佳化:直接使用 markitdown 命令列工具進行轉換
  • 最佳化:增加 markitdown 命令的自動檢測邏輯

  • v1.0.3 (2026-03-12)

  • 修復:移除不存在的 --temp-dir 引數
  • 更新:完善所有支援的檔案型別說明
  • 最佳化:文件與實際指令碼保持一致

  • v1.0.2 (2026-03-11)

  • 最佳化:移除臨時目錄,直接生成 .md 檔案
  • 新增:.docx 檔案 LibreOffice 直接轉換
  • 最佳化:convert_modern 支援引數呼叫
  • 最佳化:批次轉換邏輯,提高速度
  • 最佳化:--dry-run 模式跳過 LibreOffice 檢查

  • v1.0.0 (2026-03-11)

  • 初始版本
  • 支援 .doc/.xls 批次轉換
  • 最佳化:LibreOffice 直接轉 Markdown
  • 分類處理,保持目錄結構

最後更新: 2026-03-12
適用平臺: Windows/Linux/macOS (需 LibreOffice)
許可證: MIT

🤖 AI 評測

這個工具質量不錯,能把 Word、Excel、PPT、PDF 文件批次轉成 Markdown 格式,中文支援好,保持原目錄結構,適合整理歷史文件庫。優點是支援的格式多、批次處理快、有預覽功能。主要問題是使用前需要手動安裝 LibreOffice 和 Python 工具,對新手不太友好,偶爾轉換大檔案時可能超時出錯。

📊 多維度評分

適應性4.3
規範性4.8
有效性4.4
可靠性4.3
可信度5

📁 包含檔案 (14 個)

📄 README.md 8.3 KB
📄 SKILL.md 8.9 KB
📄 USAGE.md 8.2 KB
📄 _meta.json 137 B
📄 manifest.json 4.9 KB
📄 package.json 721 B
📄 references/API_REFERENCE.md 9.5 KB
📄 references/CONFIGURATION.md 9 KB
📄 references/EXAMPLES.md 16.9 KB
📄 references/FORMATS.md 9.9 KB
📄 references/INDEX.md 2.2 KB
📄 references/PERFORMANCE.md 10.1 KB
📄 references/TROUBLESHOOTING.md 10.3 KB
📄 scripts/batch_convert.py 18.7 KB