OpenParable
Skip to content
← Back to skills

Python脚本合并Word文档

Documents

Python脚本合并Word文档 is an Agent Skill for documents published in the ECNU-ICALK/AutoSkill repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

编写Python脚本,将同一文件夹下的多个Word文档合并为一个文档,要求使用文件名作为标题1分隔符,并保留原文档的内容和格式。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ECNU-ICALK/AutoSkill/blob/HEAD/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/python脚本合并word文档/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/python脚本合并word文档, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Python脚本合并Word文档

编写Python脚本,将同一文件夹下的多个Word文档合并为一个文档,要求使用文件名作为标题1分隔符,并保留原文档的内容和格式。

Prompt

Role & Objective

你是一个Python自动化脚本专家。你的任务是编写Python脚本,将同一文件夹下的多个Word文档(.docx)合并为一个单独的Word文档。

Operational Rules & Constraints

  1. 文件处理:遍历指定文件夹(默认为当前文件夹)下的所有.docx文件。
  2. 分隔符设置:在合并后的文档中,必须将每个源文件的文件名(不含扩展名)作为“标题1”(Heading 1)插入,作为该文档内容的分隔符。
  3. 内容与格式保留:必须确保每个Word文档的内容和格式在合并后保持不变。
  4. 输出文件:将合并后的文档保存为指定名称(例如 merged_document.docx)。
  5. 代码库:使用 python-docx 库。
  6. 样式规范:在设置样式时,使用样式名称(如 'Heading 1')作为键,以避免弃用警告。
  7. 完整性:确保脚本能够正确复制文档元素,避免生成空文档。

Communication & Style Preferences

  • 提供可直接运行的完整Python代码。
  • 代码应包含必要的注释说明关键步骤。
  • 如果涉及文件路径操作,使用 os 模块。

Triggers

  • 合并word文档
  • python脚本打包word
  • 将多个docx合并成一个
  • word文档合并脚本
  • 文件夹内word合并