Back to blog
Mar 07, 2025
6 min read

How to Automate Daily Tasks with Python Scripts

Learn how to use Python to automate repetitive daily tasks, improve efficiency, and save time with simple scripts.

How to Automate Daily Tasks with Python Scripts

Python is one of the best programming languages for automation, allowing you to eliminate repetitive tasks and save time. Whether it’s renaming files, sending emails, scraping websites, or organizing data, Python makes automation simple and efficient.

In this guide, we’ll explore how to automate daily tasks using Python and provide real-world examples with step-by-step scripts.


1. Why Automate with Python?

Automation reduces manual effort, eliminates human errors, and saves time. Python is particularly good for automation because:

Simple syntax → Easy to learn and write. ✔ Huge library ecosystem → Supports automation tools like os, shutil, selenium, and pandas. ✔ Cross-platform compatibility → Works on Windows, macOS, and Linux. ✔ Scalability → Scripts can be extended for complex tasks.

Python can automate tasks such as:

  • File and folder management
  • Web scraping for data collection
  • Email and messaging automation
  • Data analysis and reporting
  • Form filling and browser automation

2. Automating File and Folder Management

A. Renaming Multiple Files in a Folder

If you have hundreds of files to rename, Python can automate it:

import os

folder_path = "C:/Users/YourName/Documents"
for index, filename in enumerate(os.listdir(folder_path)):
new_name = f"file_{index+1}.txt"
os.rename(os.path.join(folder_path, filename), os.path.join(folder_path, new_name))

print("Renaming completed!")

Use Case: Rename files with sequential names (file_1.txt, file_2.txt, etc.).


B. Organizing Files into Folders Based on Type

You can automatically sort files into folders based on their extensions:

import os
import shutil

folder_path = "C:/Users/YourName/Downloads"
file_types = {
"Images": [".jpg", ".png", ".jpeg"],
"Documents": [".pdf", ".docx", ".txt"],
"Videos": [".mp4", ".mov"]
}

for filename in os.listdir(folder_path):
file_ext = os.path.splitext(filename)[1]
for folder, extensions in file_types.items():
if file_ext in extensions:
dest_folder = os.path.join(folder_path, folder)
if not os.path.exists(dest_folder):
os.makedirs(dest_folder)
shutil.move(os.path.join(folder_path, filename), dest_folder)

print("Files sorted successfully!")

Use Case: Automatically move images, documents, and videos into specific folders.


3. Automating Web Scraping

Python can extract information from websites using BeautifulSoup and requests.

A. Scraping Product Prices from an E-Commerce Website

import requests
from bs4 import BeautifulSoup

url = "https://example.com/product-page"
headers = {"User-Agent": "Mozilla/5.0"}
response = requests.get(url, headers=headers)

soup = BeautifulSoup(response.text, "html.parser")
price = soup.find("span", class_="product-price").text

print(f"The current price is: {price}")

Use Case: Get real-time price updates from an online store.


B. Scraping News Headlines from a Website

import requests
from bs4 import BeautifulSoup

url = "https://news.ycombinator.com/"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")

headlines = soup.find_all("a", class_="storylink")

for index, headline in enumerate(headlines[:5]):
print(f"{index+1}. {headline.text} - {headline['href']}")

Use Case: Extract latest news headlines from a website.


4. Automating Email and Messaging

A. Sending Automated Emails

You can send automated emails using Python’s smtplib:

import smtplib
from email.mime.text import MIMEText

sender_email = "your_email@example.com"
receiver_email = "recipient@example.com"
password = "your-email-password"

msg = MIMEText("Hello! This is an automated email from Python.")
msg["Subject"] = "Automated Email"
msg["From"] = sender_email
msg["To"] = receiver_email

with smtplib.SMTP("smtp.gmail.com", 587) as server:
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, msg.as_string())

print("Email sent successfully!")

Use Case: Automate daily report emails or reminder notifications.


B. Sending WhatsApp Messages with Twilio API

You can automate WhatsApp messages using twilio:

from twilio.rest import Client

account_sid = "your_account_sid"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)

message = client.messages.create(
from_="whatsapp:+14155238886",
body="Hello! This is an automated message.",
to="whatsapp:+1234567890"
)

print(f"Message sent with SID: {message.sid}")

Use Case: Send daily reminders or alerts via WhatsApp.


5. Automating Data Processing and Reporting

A. Automating Excel File Updates with Pandas

Python’s pandas library can automate spreadsheet updates:

import pandas as pd

# Read Excel file
df = pd.read_excel("data.xlsx")

# Process data
df["Total"] = df["Quantity"] * df["Price"]

# Save updated file
df.to_excel("updated_data.xlsx", index=False)

print("Excel file updated successfully!")

Use Case: Automate data analysis and financial reports.


6. Automating Form Filling with Selenium

A. Auto-Filling Web Forms

Use Selenium to automate login and form submission:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://example.com/login")

username = driver.find_element("name", "username")
password = driver.find_element("name", "password")

username.send_keys("your_username")
password.send_keys("your_password")

driver.find_element("name", "login").click()

print("Login successful!")

Use Case: Automate logging into websites or filling forms.


7. Running Python Automation Scripts on a Schedule

To run scripts automatically, use Windows Task Scheduler (Windows) or cron (Linux/Mac).

A. Scheduling a Python Script on Windows

  1. Open Task Scheduler and create a new task.
  2. Set Trigger → “Daily” or “Every Hour”.
  3. Set Action → “Start a Program” → Browse and select your Python script.
  4. Click OK → Python script will now run automatically.

B. Running a Python Script at Startup (Linux/macOS)

Add the script to crontab:

crontab -e

Add this line to run the script every day at 8 AM:

0 8 * * * /usr/bin/python3 /home/user/script.py

Conclusion

Python automation can save hours of repetitive work, from file management and data analysis to web scraping and messaging. With simple scripts, you can increase productivity and efficiency.

Key Takeaways

Automate file management, emails, and messaging. ✔ Use Selenium to fill forms and log in automatically. ✔ Schedule tasks using Task Scheduler or cron jobs. ✔ Python makes automation accessible for everyone!

Start automating today with Python! 🚀


Disclaimer

Article written with the help of AI.

This blog post is for informational purposes only and is not affiliated with or endorsed by any mentioned company. References are for discussion, not promotion. Some information may be inaccurate, readers should verify independently before making decisions.