T

tomark-skill

辦公效率v1.0.0
作者:user_f474679a更新於 2026-10-01@user_f474679a/tomark-skill
檔案處理流程自動化

據 AlphaMoat 統計,截至 2026-09,tomark-skill 累計下載 1,201 次、獲 0 個星標,在全部 5,078 個 AI 技能中排名第 4,936 位,在「辦公效率」分類(435 個)中排名第 415 位。

累計安裝
129
累計下載
1201
星標
-
全站排名
#4,936
全站前 98% · 「辦公效率」前 96%
平台累計安裝累計下載星標評論
SkillHub ↗1291201-—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

該技能把 DOCX 文件轉換為 Markdown,並可按原有結構保留標題、粗體與列表;DOC 和 WPS 檔案需要先透過 Windows 上的 WPS Office COM 轉為 DOCX,再繼續轉換。批次任務可保留子目錄結構。執行前應確認檔案範圍、目標目錄以及所需轉換環境,尤其是舊格式對 Windows/WPS 的依賴。

資料釋出於 2026-10-29

可以用來做什麼

  • 將單個 DOCX 檔案轉換為 Markdown
  • 批次轉換 DOC、DOCX 或 WPS 文件
  • 保留批次輸入的子目錄結構

什麼時候用

  • 使用者要求將 Word/WPS 檔案轉為 Markdown 時
  • 目標檔案格式和輸出位置已確認時
  • 可以提供所需的 mammoth 或 Windows/WPS 轉換環境時

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

將這個資料夾中的 DOCX 文件批次轉為 Markdown,並保留子目錄結構;先列出將處理的檔案和輸出目錄。

月度資料趨勢

累計下載1201
264612902026-03 · 累計下載 912026-05 · 累計下載 4342026-06 · 累計下載 5802026-07 · 累計下載 8202026-08 · 累計下載 9522026-09 · 累計下載 120126-0326-09
星標-
0112026-03 · 星標 -2026-05 · 星標 -2026-06 · 星標 -2026-07 · 星標 -2026-08 · 星標 -2026-09 · 星標 -26-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-091201—-
2026-08952+16.1%-
2026-07820+41.4%-
2026-06580+33.6%-
2026-05434—-
2026-0391—-

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

3.5 KB · SkillHub v1.0.0
---
name: tomark-skill
description: >
  This skill should be used when the user wants to convert documents (.doc, .docx, .wps)
  to Markdown format — either a single file or an entire folder in batch.
  Trigger phrases include: "转为markdown", "转成md", "文档转markdown", "批量转换markdown",
  "convert to markdown", "doc to md", "wps转markdown".
  Provides a ready-to-run Python script that handles .docx (via mammoth), and .doc/.wps
  (via WPS Office COM automation on Windows), producing clean Chinese-language Markdown
  with no garbled characters.
展開全部(共 130 行)
---

# tomark-skill — 文档批量转 Markdown

## Overview

To convert Word/WPS documents (.doc, .docx, .wps) to Markdown (.md) format.

**Supported formats:**
- `.docx` — converted via `mammoth` (preserves headings, bold, lists)
- `.doc` / `.wps` — converted via WPS Office COM (`KWps.Application`) to .docx first, then mammoth
- Batch or single file, with sub-directory structure preserved

**Prerequisites (Windows):**
- Python 3.x
- `mammoth` library: `pip install mammoth`
- `pywin32` library: `pip install pywin32`
- WPS Office installed (for .doc/.wps files)

---

## Workflow Decision Tree

```
User request
    │
    ├─ Single file?
    │       └─ Call convert_file() directly
    │
    └─ Folder / batch?
            └─ Run scripts/convert_to_markdown.py with SRC_DIR set
```

---

## Step 1 — Check Prerequisites

To verify the environment before running:

```python
import shutil, importlib

# Check mammoth
try:
    import mammoth
    print("mammoth: ok")
except ImportError:
    print("mammoth: MISSING — run: pip install mammoth")

# Check pywin32 (for .doc/.wps)
try:
    import win32com.client
    print("pywin32: ok")
except ImportError:
    print("pywin32: MISSING — run: pip install pywin32")

# Check WPS Office
import glob
wps = glob.glob("C:/Program Files (x86)/Kingsoft/WPS Office/*/office6/wps.exe")
print("WPS Office:", wps[0] if wps else "NOT FOUND")
```

If WPS Office is not installed, `.doc`/`.wps` files cannot be converted.
Only `.docx` files can be processed with mammoth alone.

---

## Step 2 — Configure and Run

To run the batch conversion script:

1. Open `scripts/convert_to_markdown.py`
2. Set `SRC_DIR` to the source folder path
3. Optionally set `OUT_DIR` (default: `<SRC_DIR>/markdown_output/`)
4. Run: `python -X utf8 scripts/convert_to_markdown.py`

To convert a single file inline:

```python
from pathlib import Path
# import the helper functions from the script
from scripts.convert_to_markdown import convert_file

src = Path(r"D:\documents\example.doc")
out = Path(r"D:\documents\example.md")
ok, msg = convert_file(src, out)
print(ok, msg)
```

---

## Step 3 — Interpret the Output

After conversion completes:

- All `.md` files are in `OUT_DIR`, mirroring the original sub-directory structure
- A `转换报告.md` report is generated listing successes and failures
- Typical failure causes:
  - WPS Office not installed (for .doc/.wps)
  - Password-protected documents
  - Severely corrupted files

---

## Encoding Notes

- Always run with `python -X utf8` on Windows to avoid GBK encoding issues
- The script forces `sys.stdout` to UTF-8 internally
- Output `.md` files are always written as UTF-8

---

## Resources

### scripts/
- `convert_to_markdown.py` — main batch conversion script (configure `SRC_DIR` at the top)

### references/
- `format_guide.md` — notes on mammoth output format and post-processing tips

「辦公效率」分類下的熱門技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。