AI SummaryA Python-based batch editing tool for Word documents that automates formatting, text replacement, and structural modifications using a three-track indexing system. Ideal for developers and content teams who need to programmatically transform multiple documents without manual XML editing.
Install
Copy this and paste it into Claude Code, Cursor, or any AI assistant:
I want to install the "docx-batch" skill in my project. Please run this command in my terminal: # Install skill into the correct directory mkdir -p .claude/skills/claude-skill-docx-batch && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/claude-skill-docx-batch/SKILL.md "https://raw.githubusercontent.com/ni1o1/claude-skill-docx-batch/master/SKILL.md" Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.
Description
高效的 Word 文档批量编辑工具,基于 python-docx 封装。适用于:(1) 批量格式化(字体、对齐、缩进、行距)(2) 段落/表格/图片的增删改 (3) 全局文本替换 (4) 清理自动编号。当需要快速统一文档格式、批量修改样式时使用此 skill,而非逐个操作 XML。
DocxEditor - Word 文档批量编辑工具
使用此 skill 前,确保已安装依赖:pip install python-docx
三轨制索引
文档由三个独立列表组成,索引互不干扰: | 轨道 | 索引参数 | 说明 | |------|----------|------| | 段落 | index | 包含标题和正文 | | 表格 | table_index | 独立于段落 | | 图片 | image_index | 独立于段落 |
工作流程
• 查询 → 获取最新索引和内容 • 构建操作列表 → 组装 batch_update 参数 • 执行 → batch_update 自动倒序执行,无需手动计算索引漂移 • 保存 → save() 写入文件
快速开始
`python import sys sys.path.insert(0, 'SKILL_DIR/scripts') # 替换为实际路径 from docx_editor import DocxEditor editor = DocxEditor('input.docx') outline = editor.get_outline() print(f"共 {outline['total']} 段落") editor.batch_update([ {'op': 'update_style', 'index': 0, 'font': {'name': '宋体'}, 'alignment': 'left'}, ]) editor.save('output.docx') `
Discussion
Health Signals
My Fox Den
Community Rating
Sign in to rate this booster