This repository contains scripts for processing Word templates (.dotx) by searching and replacing specific text in headers, footers, or the main text body. The setup script ensures that all necessary Python packages are installed and the environment is ready for use.
Go to file
2024-08-30 08:58:51 +00:00
dotx_processor.py added files 2024-08-30 08:44:21 +00:00
README.md README.md aktualisiert 2024-08-30 08:58:51 +00:00
setup_environment.py added files 2024-08-30 08:44:21 +00:00

WordTemplateProcessor

This repository provides scripts for processing Word templates (.dotx) by searching and replacing specific text within headers, footers, or the main text body. It includes a setup script to ensure all necessary Python packages are installed.

Files

  • setup_environment.py: This script checks if pip is installed, installs it if necessary, and then installs the required Python packages.
  • dotx_processor.py: This script processes .dotx files in a specified directory, replacing specified text in headers, footers, or the main text.

Requirements

  • Python 3.x
  • Microsoft Word installed
  • Internet connection to install packages

Usage

  1. Setup the Environment:

    Run the setup_environment.py script to ensure pip and required packages are installed:

    ```bash py setup_environment.py`

  2. Run the Processor Script:

    Execute the dotx_processor.py script to process Word templates:

    ```bash py dotx_processor.py`

  3. Follow the Prompts:

The script will prompt you for the following inputs:

  • Path to the input directory: Enter the path where your .dotx files are located.
  • Path to the output directory: Enter the path where you want the modified files to be saved.
  • Area for text replacement: Choose where to replace the text (Header, Footer, or Text).
  • Text to find: Enter the exact text string you want to search for in the documents.
  • Text to replace with: Enter the new text string that will replace the found text.

Example Usage

  1. Run the setup script to ensure the environment is prepared:

    ```bash py setup_environment.py`

This command will install pip if it is not already installed and then use it to install the necessary Python packages (pywin32).

  1. Run the processing script to start modifying your .dotx files:

    ```bash py dotx_processor.py`

After running this command, follow the on-screen prompts to specify the directories and text replacement details.

Notes

  • Ensure that Word documents are not open in other applications while running the script to avoid file access issues.
  • The output directory must have write permissions for the modified files to be saved correctly.
  • Use absolute paths for the input and output directories to avoid path resolution issues.

License

This project is licensed under the MIT License - see the LICENSE file for details.