Python · Intermediate level

Intermediate level · Module 5: Automating Everyday Office Tasks with Python · Lesson 3 of 4

Generating Standard Documents and Scheduling Scripts

Produce repeatable text documents (letters, summaries) from templates and run scripts automatically on a schedule.

In this lesson you will

  • Fill text templates with data
  • Schedule a script with Windows Task Scheduler or cron

Key concepts

string.Template / f-string templatesbatch generationscheduled taskexit codes

The lesson

Many offices send the same letter to many people with small changes: fee reminders, appointment notices, certificates. A template string with placeholders filled from data produces one correct document per person.

Check each generated document against the data, especially names and amounts. One wrong figure in a payment reminder damages trust.

Scheduling runs a script automatically: Task Scheduler on Windows or cron on Linux. A scheduled script must log what it did, because nobody is watching it run.

Step by step

  1. Write a letter template with placeholders for name, balance and due date.
  2. Loop over the fee records and write one file per learner.
  3. Spot-check three letters against the data.
  4. Schedule the script weekly with Task Scheduler or cron.

Practice activity

Generate personalised payment-reminder letters (text files) for a list of school fee balances and schedule the script to run every Monday.

Expected result: One correctly personalised letter per record and a working scheduled task.

Check your understanding

  1. Why log the outcome of a scheduled script?

    Show answer

    Nobody watches it run, so a log is the only evidence it worked or why it failed.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.