We all have those repetitive tasks on our computers: renaming hundreds of files, clicking the same sequence of buttons, or moving files between folders.

You don't have to do them manually anymore. Python is not just for building websites or AI models; it is the most powerful tool on your PC for automating boring tasks.

Here are three practical Python scripts you can copy and run today to automate your Windows workflow.

Prerequisite: Install Python

If you don’t have Python installed, download it from python.org. During installation, make sure to check the box that says "Add Python to PATH".

Once installed, open your Command Prompt and install the automation library we will use for the mouse and keyboard:

bash

pip install pyautogui

Automation 1: Bulk Rename Files

If you download hundreds of images or documents, they probably have messy names like IMG_9843.jpg. Renaming them one by one takes forever.

Create a file called rename.py, put it in the folder with your files, and run this:

python

import os

folder_path = "." # The current folder
prefix = "Project_File_" 

# Get all files in the folder
files = os.listdir(folder_path)

count = 1
for filename in files:
    # Skip the python script itself
    if filename == "rename.py":
        continue
        
    # Get the file extension (e.g., .jpg)
    file_extension = os.path.splitext(filename)[1]
    
    # Create the new name
    new_name = f"{prefix}{count}{file_extension}"
    
    # Rename the file
    os.rename(filename, new_name)
    count += 1

print("All files renamed successfully!")

This script will rename every file in that folder to Project_File_1.jpg, Project_File_2.jpg, and so on.

Automation 2: Auto-Clicker & Mouse Mover

Are you playing a game that requires you to stay active, or doing a task where you need the mouse to keep moving so your PC doesn't go to sleep?

With pyautogui, you can control your mouse and keyboard directly. Create mouse.py:

python

import pyautogui
import time

print("Automation starting in 3 seconds. Move your mouse to the target.")
time.sleep(3) # Gives you 3 seconds to move your mouse

# Loop 10 times
for i in range(10):
    # Get current mouse position
    x, y = pyautogui.position()
    
    # Click the left mouse button
    pyautogui.click(x, y)
    
    # Wait 1 second
    time.sleep(1)
    
    # Move mouse slightly (prevents sleep mode)
    pyautogui.moveRel(10, 0, duration=0.2)
    pyautogui.moveRel(-10, 0, duration=0.2)

Automation 3: Open Your Entire Work Setup

Every morning, you probably open Chrome, Slack, your code editor, and Spotify manually. You can write a script to open all of them instantly.

Create start_work.py:

python

import os

# List of applications to open
apps = [
    "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
    "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\slack\\slack.exe",
    "C:\\Program Files\\Spotify\\Spotify.exe"
]

for app in apps:
    try:
        os.startfile(app)
        print(f"Opened: {app}")
    except Exception as e:
        print(f"Failed to open {app}: {e}")

(Note: You will need to replace YOUR_USERNAME and the paths with the actual locations of your installed apps).

Taking the Next Step

These scripts are just the tip of the iceberg. With Python, you can automate Excel spreadsheets, scrape websites for data, and even build bots that interact with your operating system.

To master the language and build more advanced automations, check out our Complete Python Masterclass.

If you are interested in how the operating system handles these files and processes in the background, our Operating Systems Masterclass breaks down exactly what happens when you run a script.

Stop doing the same thing twice. Write a script, let Python do it, and focus on the work that actually matters.