10 Python Automation Scripts for Beginners (With Ready-to-Use Code)

10 ready-to-use Python automation scripts for beginners with full code and line-by-line explanations. Automate files, emails, backups and more today.

Looking for python automation scripts for beginners that you can actually run today? You are in the right place. Automation is one of the most practical reasons to learn Python: with just a few lines of code, you can rename hundreds of files, organize messy folders, or send emails automatically. In this guide, you will get 10 ready-to-use python scripts for beginners, each one explained line by line, so you understand not just what the code does, but how it works.

Why Python Automation Scripts Are Perfect for Beginners

If you are new to coding, automation is the fastest way to feel the power of programming. Instead of abstract exercises, you solve real problems on your own computer from day one. Here is why Python is the best language for it:

  • Readable syntax: Python code reads almost like English, so python automation scripts for beginners are easy to follow even if this is your first language.
  • Batteries included: The standard library ships with modules like os, shutil, csv, json, and smtplib, so you can automate tasks with Python without installing anything extra.
  • Instant results: Rename 500 photos in two seconds and you will never doubt that coding is worth learning.
  • Career value: Employers love candidates who automate repetitive work. Small python automation projects on your resume signal real-world problem solving.

If you are still deciding whether Python is the right first language, read our guide on the best programming language to learn first in 2026 before diving in.

What You Need Before You Start

Every script below assumes you have:

  1. Python 3 installed. Download it free from python.org. During installation on Windows, check the box that says “Add python.exe to PATH”.
  2. A code editor. VS Code or even Notepad will do. Save each script as a .py file.
  3. How to run a script: Open your terminal, navigate to the script’s folder, and type python script_name.py.
  4. One extra library: Script 4 and 9 use the requests library. Install it once with pip install requests.

New to coding entirely? Our complete beginner roadmap for learning coding from scratch walks you through the very first steps.

10 Python Automation Scripts for Beginners

Here are ten practical scripts, ordered from easiest to slightly more advanced. Copy each one, run it, then tweak it — breaking and fixing code is how you learn.

1. Bulk File Renamer

Downloaded 200 photos named IMG_0042.jpg? This script renames every file in a folder to a clean numbered sequence like photo_1.jpg, photo_2.jpg.

import os

folder = "photos"  # change to your folder name
prefix = "photo"

files = sorted(os.listdir(folder))
for i, filename in enumerate(files, start=1):
    extension = os.path.splitext(filename)[1]
    new_name = f"{prefix}_{i}{extension}"
    os.rename(os.path.join(folder, filename),
              os.path.join(folder, new_name))
    print(f"Renamed {filename} -> {new_name}")

How it works: os.listdir() grabs every file name, os.path.splitext() keeps the original extension, and os.rename() does the renaming. The f"..." syntax is an f-string — Python’s cleanest way to build text from variables.

2. Downloads Folder Organizer

This classic beginner automation script sorts a messy folder into subfolders by file type — images, documents, videos, and everything else.

import os
import shutil

folder = "downloads"  # change to your folder path

EXTENSIONS = {
    "images": [".jpg", ".png", ".gif"],
    "documents": [".pdf", ".docx", ".txt"],
    "videos": [".mp4", ".mov", ".avi"],
}

for filename in os.listdir(folder):
    path = os.path.join(folder, filename)
    if not os.path.isfile(path):
        continue
    ext = os.path.splitext(filename)[1].lower()
    category = "other"
    for name, exts in EXTENSIONS.items():
        if ext in exts:
            category = name
    dest = os.path.join(folder, category)
    os.makedirs(dest, exist_ok=True)
    shutil.move(path, os.path.join(dest, filename))
    print(f"Moved {filename} -> {category}/")

Try it: Add your own categories, like ".mp3" for music or ".zip" for archives. To automate tasks with Python on a schedule, run this script weekly with Task Scheduler (Windows) or cron (Mac/Linux).

3. Automatic Email Sender

Send emails straight from Python — handy for daily reports, reminders, or notifications from your other scripts.

import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["From"] = "you@example.com"
msg["To"] = "friend@example.com"
msg["Subject"] = "Automated hello from Python"
msg.set_content("This email was sent by a Python script!")

with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
    server.login("you@example.com", "your-app-password")
    server.send_message(msg)
print("Email sent!")

Important: For Gmail, you must create an App Password in your Google account settings — your regular password will not work. Never hard-code real passwords in scripts you share; use environment variables instead.

4. Website Headline Scraper

This script fetches a news homepage and prints the headlines — your first step into web scraping and working with data from the internet.

import re
import requests

url = "https://example.com"
html = requests.get(url, timeout=10).text

# find text inside <h2> tags (simple approach)
headlines = re.findall(r"<h2.*?>(.*?)</h2>", html, re.DOTALL)
for h in headlines[:10]:
    clean = re.sub(r"<.*?>", "", h).strip()
    if clean:
        print("-", clean)

How it works: requests.get() downloads the page HTML, and a regular expression pulls out headline text. For bigger scraping projects, graduate to the BeautifulSoup library. Always check a site’s terms of service before scraping it.

5. CSV to JSON Converter

Data comes in CSV files; programs love JSON. This script converts between the two using only the standard library — no installs needed.

import csv
import json

with open("data.csv", newline="", encoding="utf-8") as f:
    rows = list(csv.DictReader(f))

with open("data.json", "w", encoding="utf-8") as f:
    json.dump(rows, f, indent=2)

print(f"Converted {len(rows)} rows to data.json")

How it works: csv.DictReader turns each row into a dictionary keyed by the header row, and json.dump writes the list of dictionaries as formatted JSON. This pattern shows up constantly in real python automation projects that move data between systems.

6. Strong Password Generator

Stop reusing weak passwords. This script generates cryptographically strong random passwords using the secrets module (built for security, unlike random).

import secrets
import string

alphabet = string.ascii_letters + string.digits + "!@#$%^&*"
length = 16

password = "".join(secrets.choice(alphabet) for _ in range(length))
print("Your new password:", password)

Try it: Change length to 20, or remove the symbols from alphabet for sites that reject them. Combine this with Script 3 to email yourself a fresh password every month.

7. Timestamped Folder Backup

One of the most useful python scripts for beginners: back up any folder with a single command, naming each backup with the date and time so nothing gets overwritten.

import shutil
from datetime import datetime
from pathlib import Path

source = Path("my_project")  # folder to back up
stamp = datetime.now().strftime("%Y-%m-%d_%H-%M")
backup = Path("backups") / f"my_project_{stamp}"

shutil.copytree(source, backup)
print(f"Backup created at {backup}")

How it works: pathlib.Path handles file paths cleanly across Windows, Mac, and Linux, datetime builds the timestamp, and shutil.copytree() copies the entire folder tree. Run this before any risky experiment and you will always have a way back.

8. Text File Merger

Have a folder full of notes or log files? This script merges every .txt file into one, with headers showing where each part came from.

from pathlib import Path

folder = Path("notes")
output = folder / "combined.txt"

with output.open("w", encoding="utf-8") as out:
    for txt_file in sorted(folder.glob("*.txt")):
        if txt_file == output:
            continue
        out.write(f"\n===== {txt_file.name} =====\n")
        out.write(txt_file.read_text(encoding="utf-8"))

print(f"Merged into {output}")

How it works: folder.glob("*.txt") finds all matching files — glob patterns are a superpower for file automation. Sorting keeps the merge order predictable.

9. Bulk Image Downloader

Given a list of image URLs, this script downloads them all into a folder — much faster than right-clicking fifty times.

import requests
from pathlib import Path

urls = [
    "https://example.com/photo1.jpg",
    "https://example.com/photo2.jpg",
]

folder = Path("images")
folder.mkdir(exist_ok=True)

for i, url in enumerate(urls, start=1):
    data = requests.get(url, timeout=15).content
    ext = url.rsplit(".", 1)[-1].split("?")[0][:4]
    path = folder / f"image_{i}.{ext}"
    path.write_bytes(data)
    print(f"Saved {path}")

Tip: Pair this with Script 4: scrape image URLs from a page, then feed them into this downloader. Respect copyright — only download images you have the right to use.

10. Pomodoro Focus Timer

Finish with a script that automates you: a Pomodoro timer that alternates 25-minute focus sessions with 5-minute breaks, right in your terminal.

import time

def countdown(minutes, label):
    total = minutes * 60
    while total:
        mins, secs = divmod(total, 60)
        print(f"\r{label}: {mins:02d}:{secs:02d}", end="")
        time.sleep(1)
        total -= 1
    print(f"\n{label} finished!")

for round_no in range(1, 5):
    countdown(25, f"Focus session {round_no}")
    if round_no < 4:
        countdown(5, "Break")

How it works: time.sleep(1) pauses one second per loop, and \r rewrites the same terminal line for a live countdown effect. Change the durations to match your own rhythm.

Tips for Building Your Own Python Automation Projects

Now that you have ten working examples, here is how to level up from copying scripts to creating your own python automation projects:

  • Start with your own annoyances. The best automation ideas come from tasks you personally repeat: renaming lecture slides, sorting screenshots, or checking a website for changes.
  • Use the standard library first. Before installing packages, check Python’s standard library docs — os, pathlib, shutil, csv, and datetime cover most beginner needs.
  • Expect errors and handle them. Wrap risky operations in try/except blocks so one bad file does not crash your whole script.
  • Test on copies. Scripts that rename, move, or delete files should first run on a disposable test folder — combined with Script 7’s backup habit, you are safe.
  • Schedule your scripts. Use Task Scheduler on Windows or cron on Mac/Linux to run scripts automatically every day or week. That is when automation truly pays off.

What’s Next

You now have ten python automation scripts for beginners in your toolkit — run them, modify them, and combine them into bigger workflows. When you are ready for larger builds, check out our 15 easy Python projects for beginners with source code to turn these skills into portfolio pieces. And if you are just starting your journey, our complete guide to learning coding from scratch in 2026 maps out exactly what to learn next. Happy automating!

Leave a Reply

Your email address will not be published. Required fields are marked *