Skip to the yard
Waxsealai

5 Practical Python Automation Scripts for Images, Files, Text and Logs

Shipped
Shipper
Bala Priya C
Readers
482

Five small Python scripts automate common image, file, text, task-list and log workflows, with practical safeguards and clear limits.

5 Practical Python Automation Scripts for Images, Files, Text and Logs

5 Useful Python Automation Scripts for Beginners

Small Python scripts can take the repetition out of everyday work without requiring a large application or a complicated workflow. These five examples cover image processing, file management, text analysis, terminal-based task tracking and log inspection. Each has a narrow purpose, making it easier to see how Python connects a problem to a repeatable operation.

The examples also introduce useful habits: preserve original files, preview changes before applying them, and make assumptions visible. The scripts are collected in a GitHub repository, where they can be inspected and adapted.

Prepare image batches in one pass

Resizing a folder of photos and adding the same watermark to each can turn a simple publishing task into a string of repetitive edits. The image script handles a batch at once: it scales each image to a chosen maximum width or height, keeps the original aspect ratio, and places text in a selected corner. Output goes to a separate folder, leaving the source images intact.

Under the hood, the script uses Pillow to open and resize images with a high-quality resampling filter. It draws the watermark with ImageDraw, placing text on a semi-transparent layer before compositing it onto the result. Unsupported files are skipped with a warning, so one problem file does not halt the batch. A final count reports how many images were processed.

This is useful when a set of pictures needs consistent dimensions and branding. The chosen maximum dimensions and watermark placement still need to match the destination; the script automates those choices across files rather than deciding them for you. View the image resizer and watermarker.

Rename files with a preview

Camera-generated names and inconsistent downloads are hard to scan, especially when many files need the same adjustment. The bulk renamer supports three rules: add a prefix or suffix, assign sequential names, or replace a piece of text in each filename.

It uses Python’s pathlib to find files and calculate their proposed names. By default, it prints a before-and-after preview without changing anything. Renaming happens only when the user supplies --apply, at which point the script calls Path.rename(). It checks for naming collisions first and stops if the planned changes would create one.

That dry-run default makes the tool easier to use safely: users can inspect the plan before committing a batch operation. It’s still sensible to check the preview carefully, particularly when a broad replacement rule could affect more filenames than intended. View the bulk file renamer.

Get a quick profile of a text file

For a draft, transcript or other plain-text file, the word-frequency analyzer reports total words and sentences, average sentence length, frequently used terms and an estimated reading time. It removes common filler words from the frequency list, helping bring more meaningful repetitions to the surface.

The script lowercases the text, strips punctuation with a regular expression, and separates it into words and sentences. It counts terms with collections.Counter and compares them with a small built-in stop-word list. Reading time is calculated from the word count using a configurable rate, set to 200 words per minute by default.

These results are a quick guide, not a full editorial assessment. The estimated time depends on the configured rate, while the frequency list depends on the included stop words and the script’s text-splitting rules. View the text analyzer.

Keep a to-do list in the terminal

A lightweight task list can be handy for people who already work in a terminal and want to avoid switching applications for a short set of tasks. This script provides four subcommands: add, list, done and remove.

Python’s argparse module handles the command-line interface and gives each subcommand its own arguments. Tasks are stored in a JSON file as dictionaries containing an ID, description, completion status and creation date. The file is read and written on each run, so the list persists between sessions. Since the data is plain JSON, it can also be inspected or backed up directly.

The simple storage model suits a personal list, while keeping the data easy to understand. View the command-line to-do list.

Filter large logs without loading them all

Finding a particular error in a long log often means narrowing the search by severity, keyword or time period. The log analyzer combines those filters and prints the number of matching lines, a breakdown by severity and the most recent matching entries.

It reads the file one line at a time, which avoids loading the full log into memory. A regular expression extracts the timestamp and severity from lines that begin with a format such as 2026-09-20 14:03:11 ERROR. Lines without the expected structure are skipped and counted. Severity, keyword and date-range filters can be combined—for example, to find error lines mentioning “timeout” within a chosen period.

The format requirement is a practical constraint: entries that do not begin with a timestamp and severity will not be analyzed as matches. For logs that follow the expected pattern, the count summary provides a quick overview before the script prints the matching details. View the log analyzer.

Match the script to the task

ScriptPurposeTypical use
Image resizer and watermarkerResize and mark images in batchesPreparing photos for a website or form
Bulk file renamerApply naming rules to a folderCleaning up filenames
Text analyzerSummarize word use and estimated reading timeReviewing a draft or transcript
To-do list managerTrack tasks from the terminalMaintaining a short task list
Log analyzerFilter and summarize log entriesSearching a large log for a specific issue

Together, the scripts show how a small amount of Python can turn a repeated manual task into a reusable command. Their value comes from clear boundaries: each handles a particular input and produces an inspectable result. As needs change, those boundaries also make the scripts straightforward to adapt—whether that means adding a naming rule, adjusting text-analysis assumptions or supporting another log format.

Source: Bala Priya C · www.kdnuggets.com

Same vesselRelated cargo