Stop Wasting Time: How to Automate Tasks with Python Scripts (Step-by-Step Guide)

Stop Wasting Time: How to Automate Tasks with Python Scripts (Step-by-Step Guide)

If you’re taking online courses—whether on Coursera, Udemy, or edX—you’ve probably hit that wall where you’re copying the same file, renaming dozens of documents, or manually checking the same website for updates. It eats into your study time and kills momentum.

Here’s the good news: you don’t need to be a full-time developer to fix this. With a little Python, you can automate those repetitive tasks in minutes. This guide will walk you through exactly how to automate tasks with Python scripts, from setting up your environment to running real-world scripts that save you hours each week.

By the end, you’ll have a reusable automation toolkit—and you’ll learn faster because you’ll spend less time on busywork.


What You’ll Need Before You Start

You don’t need much. Here’s the short list:

  • A computer (Windows, Mac, or Linux)
  • Python installed (version 3.7 or newer recommended)
  • A text editor or IDE (VS Code is free and excellent—you can download it here)
  • Basic familiarity with opening a terminal or command prompt
  • Patience for one or two installations (we’ll walk through them)

If you haven’t installed Python yet, head to python.org and download the latest version. During installation on Windows, make sure you check the box that says “Add Python to PATH.” That step saves you a headache later.


Step 1: Install Python and Essential Libraries

Once Python is installed, open your terminal (Command Prompt on Windows, Terminal on Mac/Linux). Type python --version to confirm it’s working. You should see something like Python 3.13.0.

Now, install the libraries that make automation easy. Run these commands one at a time:

pip install os
pip install shutil
pip install schedule
pip install requests
pip install PyAutoGUI

These libraries handle file operations, scheduling, web requests, and GUI automation. You won’t use all of them at once, but having them ready means you can jump into any task without pausing to install.


Step 2: Understand What You Can Actually Automate

Before writing code, let’s get realistic. Python scripts are excellent for:

  • Renaming, moving, or copying files and folders
  • Downloading lecture notes or resources from a course page
  • Reminding you when a new module drops on a learning platform
  • Converting file formats (e.g., .docx to .pdf)
  • Scheduling email reminders for assignment deadlines
  • Cleaning up your downloads folder automatically

Stick to tasks that follow a clear, repetitive pattern. Avoid attempts at complex AI or natural language processing unless you’re ready for a steep learning curve. Start small.


Step 3: Write Your First Automation Script (File Organizer)

Let’s build a script that organizes your messy Downloads folder by file type. This is the classic “first automation” and it’s genuinely useful.

Create a new file called organizer.py in your editor. Paste this code:

import os
import shutil

# Set your downloads folder path
downloads_path = r"C:\Users\YourName\Downloads"  # Windows example
# For Mac: /Users/YourName/Downloads
# For Linux: /home/YourName/Downloads

# Define folder names for each file type
file_types = {
    "Images": [".jpg", ".jpeg", ".png", ".gif", ".svg"],
    "Documents": [".pdf", ".docx", ".txt", ".xlsx", ".pptx"],
    "Videos": [".mp4", ".mov", ".avi", ".mkv"],
    "Audio": [".mp3", ".wav", ".aac"],
    "Archives": [".zip", ".rar", ".tar", ".gz"],
    "Code": [".py", ".js", ".html", ".css", ".json"]
}

# Create folders and move files
for folder_name, extensions in file_types.items():
    folder_path = os.path.join(downloads_path, folder_name)
    os.makedirs(folder_path, exist_ok=True)

    for filename in os.listdir(downloads_path):
        file_path = os.path.join(downloads_path, filename)
        if os.path.isfile(file_path):
            ext = os.path.splitext(filename)[1].lower()
            if ext in extensions:
                shutil.move(file_path, os.path.join(folder_path, filename))
                print(f"Moved {filename} to {folder_name}")

print("Organization complete!")

How to run it: In your terminal, navigate to the folder containing organizer.py and type:

python organizer.py

The first time you run this, review what it moved. Tweak the file type lists to match what you actually download. Many students add a “CourseNotes” folder for .pdf and .docx files specifically tied to their active courses.


Step 4: Automate Your Study Schedule with Email Reminders

Staying on top of deadlines is half the battle in online learning. Here’s how to write a script that sends you an email reminder before your weekly quiz or project submission.

Create a new file study_reminder.py:

import smtplib
from email.message import EmailMessage
import schedule
import time

def send_reminder():
    sender_email = "your_email@gmail.com"
    sender_password = "your_app_password"  # Use Gmail App Password, not your regular password
    recipient = "your_email@gmail.com"

    msg = EmailMessage()
    msg.set_content("Reminder: Your Python Automation assignment is due in 2 hours!")
    msg["Subject"] = "📚 Study Reminder"
    msg["From"] = sender_email
    msg["To"] = recipient

    with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
        server.login(sender_email, sender_password)
        server.send_message(msg)
        print("Reminder sent!")

# Schedule it every Tuesday and Thursday at 9:00 AM
schedule.every().tuesday.at("09:00").do(send_reminder)
schedule.every().thursday.at("09:00").do(send_reminder)

print("Reminder script running... Press Ctrl+C to stop.")
while True:
    schedule.run_pending()
    time.sleep(60)

Important security note: If you use Gmail, generate an App Password from your Google Account settings (under Security > 2-Step Verification > App Passwords). Never paste your regular password into a script.


Step 5: Scrape Course Announcements or New Content

Many learning platforms post updates that you currently refresh manually. You can automate checking for updates using the requests and BeautifulSoup libraries. First, install BeautifulSoup:

pip install beautifulsoup4

Here’s a simple script that checks if a specific webpage (for example, a course syllabus page) has changed since your last check:

import requests
import hashlib
import time

url = "https://www.coursera.org/learn/your-course"
previous_hash = ""

while True:
    response = requests.get(url)
    current_hash = hashlib.md5(response.text.encode()).hexdigest()

    if previous_hash == "":
        previous_hash = current_hash
        print("Initial snapshot taken.")
    elif current_hash != previous_hash:
        print("⚠️ Course page has changed! Check for new content.")
        # You could also trigger the email reminder here
        previous_hash = current_hash
    else:
        print("No changes detected.")

    time.sleep(3600)  # Check every hour

Pro tip: Some platforms require login to see full content. For those cases, you’ll need to include session cookies or use a library like selenium—but that’s a more advanced topic for later.


Step 6: Automate File Conversion (e.g., Lecture Notes to PDF)

If you receive course materials in .docx or .txt format and prefer everything as PDF, Python can help. Use the docx2pdf library:

pip install docx2pdf

Then create convert_to_pdf.py:

from docx2pdf import convert
import os

lecture_dir = r"C:\Users\YourName\Desktop\Course Notes"

for file in os.listdir(lecture_dir):
    if file.endswith(".docx"):
        full_path = os.path.join(lecture_dir, file)
        print(f"Converting {file}...")
        convert(full_path)
        print("Done!")

print("All documents converted to PDF.")

This script processes every Word document in your course notes folder and saves a PDF version in the same location. Great for keeping a clean, universally readable study library.


Common Mistakes Beginners Make (And How to Avoid Them)

1. Forgetting to use raw strings for Windows file paths

Windows paths use backslashes (\) which Python interprets as escape characters. Always prefix with r, like r"C:\Users\Name".

2. Accidentally moving scripts into the folders they’re organizing

If you run the file organizer from inside your Downloads folder, it might try to move itself. Keep your .py files in a separate Scripts folder on your Desktop.

3. Running scripts without a test mode first

Before running a script that moves or deletes files, add dry_run = True at the top and wrap destructive commands in an if not dry_run: block. Print the actions instead of executing them. Once you confirm the logic is right, set it to False.

4. Hardcoding paths you’ll forget

Use os.path.expanduser("~") to get the home directory dynamically. For example:

downloads_path = os.path.join(os.path.expanduser("~"), "Downloads")

5. Overcomplicating the first project

Don’t try to build a full desktop application on day one. Stick to scripts that do one thing well. Complexity kills momentum.


Frequently Asked Questions

Q: I’m a complete beginner. Can I still learn how to automate tasks with Python scripts?

Absolutely. The scripts above require zero prior coding experience beyond copying and pasting text. If you can follow a recipe, you can run these automations. The key is starting with the file organizer—it’s short, it works instantly, and it gives you confidence.

Q: Will these scripts work on Mac or Linux?

Yes, with one caveat: adjust the file paths from Windows format to Unix format. For Mac, use /Users/YourName/Downloads. For Linux, use /home/YourName/Downloads. The os module handles the rest automatically.

Q: Do I need to know how to code to take an online course on automation?

No, but it helps. Many platforms like Coursera and Udemy offer “Python for Beginners” courses that teach exactly this. Once you’ve learned the basics from a structured course, these automation scripts become your real-world practice.

Q: How do I run a script automatically every day without thinking about it?

Use the schedule library (we showed this in Step 4) for simple tasks. For more robust scheduling, set up a cron job (Mac/Linux) or Task Scheduler (Windows) to launch your Python script at specified times. That way you don’t even need the terminal open.

Q: Is it safe to use scripts that interact with websites?

Generally yes, if you’re only checking public information. But respect the website’s robots.txt file, don’t send too many requests too fast, and never scrape content behind a login wall without permission. For learning platforms, stick to content you already have access to.

Q: What if my script breaks after an update to the website or software?

That happens. When a website changes its layout, your scraper might stop working. When a Python library updates, old functions may be deprecated. The fix is usually minor: check the documentation, update a class name, or reinstall the library. This is normal maintenance—don’t let it discourage you.


Recommended Resources to Deepen Your Skills

If you want to go beyond the scripts in this guide, consider structured learning. Here are a few highly-rated courses that match this topic:

  • “Automate the Boring Stuff with Python” on Udemy — A practical course that directly teaches the same type of scripts we covered. Often goes on sale for under $20. Worth every penny for the real-world projects.
  • “Python for Everybody” Specialization on Coursera — More comprehensive, takes you from zero to intermediate. It includes automation elements but also covers databases and data structures.
  • “Learn Python 3” on Codecademy — Interactive, browser-based practice. Great if you want to try coding before installing anything.

Full disclosure: Some links above are affiliate links. They help support this content at no extra cost to you.


Final Thoughts: Start Small, Automate One Thing Today

Automation with Python isn’t about writing thousands of lines of code. It’s about identifying one boring, repetitive task and writing 10 lines to eliminate it. That one win snowballs.

Pick the file organizer script from Step 3. Run it on a test folder (not your real Downloads yet). See how satisfying it is to watch files sort themselves. Then tweak it for your own needs—maybe add a “Course Materials” folder that your script recognizes by filename patterns like “Coursera_” or “lecture_.”

Once you’ve done that, you’ve stopped being someone who “wants to learn Python” and become someone who actually uses Python to make learning itself easier. That shift is the whole point of online education: using tools to free up your time for the work that matters.

So go ahead. Open your editor. Paste a script. Run it. And take back an hour of your week.


This page may contain affiliate links. We may earn a commission on qualifying purchases at no extra cost to you.

Leave a Comment

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

Scroll to Top