My Handy Utility Scripts Collection

Mithul Pranav | May 30, 2026 min read

Sometimes the biggest productivity killers aren’t massive architectural problems, they’re the tiny, repetitive tasks you do every single day. Over time, I’ve built a small collection of utility scripts to automate these minor annoyances away.

Here is a look at some of my scripts that save me time on a regular basis.


1. PDF Page Extractor (pdfpage.py)

We’ve all been there: you have a massive 100-page PDF, but you only need pages 4, 7, and 12-15 to send to someone. Opening a heavy PDF editor just to extract a few pages feels like overkill.

To solve this, I wrote a simple command-line Python script using the pypdf library.

How it works: You just pass the input PDF and a string of the pages or page ranges you want.

python pdfpage.py input.pdf "1,2,4-6,8" [output.pdf]

It parses the page ranges, handles the 0-indexing behind the scenes, and spits out a new PDF with exactly what you asked for. If you don’t specify an output file name, it intelligently generates one for you (e.g., document_pages_1_2_4-6.pdf). No more bloated PDF software or websites required.

2. Directory Tree Generator (tree.py)

When documenting projects or sharing folder structures with colleagues, standard screenshotting just doesn’t cut it. You want something text-based that you can drop into a Markdown file or a chat message.

While Windows has a built-in tree command, it can sometimes be clunky to route its output to your clipboard or format it nicely for modern text editors.

I built tree.py to recursively scan a folder and instantly copy a perfectly formatted, Windows-style directory tree straight to your clipboard using the pyperclip library.

How it works:

python tree.py "C:\Your\Folder\Path"

It uses standard box-drawing characters (├──, └──, ) to draw the hierarchy, gracefully handles “Permission Denied” errors, and ensures directories are listed before files. As soon as the script finishes, you can just Ctrl+V the output wherever you need it!

3. Line Deletion Shortcuts (home_end_del.ahk)

This last one isn’t Python, it’s AutoHotkey v2.

When I’m coding or writing, I frequently need to delete everything from my cursor to either the beginning or the end of the current line. Reaching for the mouse to highlight the text, or spamming the backspace/delete key gets frustrating.

This lightweight script runs in the background and sets up two global hotkeys:

  • Ctrl + Win + Home : Instantly deletes everything from the cursor to the beginning of the line.
  • Ctrl + Win + End : Instantly deletes everything from the cursor to the end of the line.

Behind the scenes, it’s just simulating the keystrokes to highlight the text (Shift + Home/End) and then immediately sending the Delete key. It’s incredibly simple, but once you get used to having it, you can’t live without it.


Wrapping Up

Building small tools for yourself is one of the most rewarding parts of programming. They might not be the next billion-dollar startup idea, but they remove friction from your daily life.

If you want to build your own, start paying attention to the tasks you perform more than three times a day. Chances are, a 50-line Python script or a quick AutoHotkey macro can do it for you!