Automations

Small tools that hold up on the second run.

Most automation scripts work once, on the author's machine, on tidy input. These are the same everyday jobs — renaming, merging, parsing, mailing — written so that they survive a name collision, a rerun, a missing field and a malformed file. Each one below states the failure it handles, because that is the part that takes the judgement.

Python 3.11+ Standard library where possible Dry run before it writes
Maritime

The ones nobody else has.

Ten years of filing these documents by hand is the reason I know what they need to validate.

01

Notice of Readiness generator

A NOR starts laytime counting, so the wording and the tendered timestamp carry real commercial weight. This builds it from structured voyage data instead of editing last voyage's file.

Handles: validates the IMO check digit, refuses to tender before the vessel arrived, and rejects an operation that is neither loading nor discharging.

stdlib onlydataclassesargparse
02

Noon report parser

Noon reports are typed by whoever had the watch, so field order and spelling drift constantly. This pulls the numbers out of free text into a CSV.

Handles: reads several label spellings, reports unreadable fields instead of guessing, and cross-checks distance against speed — 305 nm at 41 kn implies a 7.4 hour day, so it says so.

stdlib onlyregexcsv
Documents and files

The boring jobs, done safely.

These are the scripts everyone writes. The difference is what happens when the input is not what you expected.

03

Batch file renamer

Adds a sequence prefix across a folder.

Handles: snapshots the listing before renaming, skips files already prefixed so a rerun is a no-op rather than rapor_0_rapor_0_x.pdf, and aborts rather than overwrite an existing name. Dry run by default.

stdlib onlypathlib
04

Folder sorter

Files a messy Downloads folder into Documents, Images, Video, Audio, Archives.

Handles: never overwrites — a clashing name becomes file (2).pdf and the original survives. Skips the category folders it created, so running it twice changes nothing.

stdlib onlyshutil
05

Excel merger

Concatenates many workbooks into one sheet.

Handles: stamps every row with its source file, and warns loudly when the workbooks do not share columns — a plain concat silently produces a sheet full of empty cells. Refuses to write the output into the folder it is reading.

pandasopenpyxl
06

PDF merger

Combines a folder of PDFs into one document.

Handles: sorts numerically, so page 10 does not land between 1 and 2 the way plain alphabetical sorting puts it. Skips encrypted files instead of raising halfway through the merge.

pypdfnatural sort
07

Report mailer

Sends a report with attachments over SMTP.

Handles: the app password comes from an environment variable and never touches the source — a password committed to git is a password to rotate. Sends a plain-text alternative alongside the HTML so the message is not blank in clients that block it.

stdlib onlysmtplibssl
Monitoring and reporting

The ones that run on a schedule.

Anything on a cron job has to fail in a way you find out about. These exit non-zero and say what went wrong, so the alert fires instead of the silence continuing.

08

FX rate watcher

Fetches exchange rates and appends a dated row to a CSV, so you accumulate a history rather than a snapshot. Defaults to TRY, BGN and EUR.

Handles: a request timeout, so a hung connection cannot block the cron slot; retries transient failures with a widening backoff; and checks the payload actually says success before indexing into it — the API answers HTTP 200 with an error body for a bad currency.

requestsretry + backoffcsv
09

Synthetic login check

Drives a real browser through your app's login flow on a schedule and captures a screenshot as evidence that it still works.

Handles: explicit waits instead of sleep(3) — a fixed guess is too short on a slow morning and wasted the rest of the time. Credentials come from the environment, the browser is always quit, and the exit code lets cron alert on failure.

seleniumexplicit waitsheadless
10

Sales charts

Turns a sales CSV into two report-ready PNGs: a monthly trend line and a ranked regional bar chart.

Handles: a font fallback chain so Turkish characters render on any machine, not just one with Arial installed. Colours are a colourblind-validated pair. Ranked bars replace the pie chart — angle is the hardest encoding to compare, and length is the easiest.

pandasmatplotlibCVD-safe
Why it matters

Automation is only worth it if you can stop watching it.

A script you have to babysit has not saved you anything. Every tool here defaults to a dry run, refuses to destroy data, and tells you what it could not do — so it can be put on a schedule and left alone.