10 Python Scripts That Will Automate Your Daily Tasks

Looking to boost your productivity with Python? This blog shares 10 powerful Python scripts that can automate your daily tasks — from cleaning up files and sending emails to scraping websites and renaming folders. Whether you’re a beginner or an experienced developer, these time-saving scripts will help simplify your workflow and give you practical tools to automate the boring stuff.

In this blog post, I will explore 10 powerful Python scripts that will make your daily digital life easier.

1. Auto-rename and organize with shutil

The shutil module in Python helps you easily copy, move, and delete files and folders. It provides simple commands for handling files in bulk.

For example, you can:

  • Copy a file or folder (shutil.copy()shutil.copytree())
  • Move (or rename) files/folders (shutil.move())
  • Delete entire folders (shutil.rmtree())

If you need to work with single files (like reading or changing permissions), you should use the os module instead.

import os
import shutil

def organize_folder(folder_path):
    for file in os.listdir(folder_path):
        full_path = os.path.join(folder_path, file)
        if os.path.isfile(full_path):
            ext = file.split('.')[-1].lower()
            folder = os.path.join(folder_path, ext + "_files")
            os.makedirs(folder, exist_ok=True)
            shutil.move(full_path, os.path.join(folder, file))

organize_folder("/path/to/your/folder")

2. Email Automation with Attachments

The smtplib module in Python lets you send emails using the SMTP (Simple Mail Transfer Protocol). It connects to an email server (like Gmail, Outlook, etc.) and sends emails directly from your Python script.

Send emails automatically with a subject, body, and attachment.

import smtplib
from email.message import EmailMessage

def send_email(subject, body, to, attachment=None):
    msg = EmailMessage()
    msg['Subject'] = subject
    msg['From'] = 'your@gmail.com'
    msg['To'] = to
    msg.set_content(body)

    if attachment:
        with open(attachment, 'rb') as f:
            file_data = f.read()
            file_name = f.name
        msg.add_attachment(file_data, maintype='application', subtype='octet-stream', filename=file_name)

    with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
        smtp.login('your@gmail.com', 'your_app_password')
        smtp.send_message(msg)

# send_email("Test Subject", "Body here", "recipient@example.com", "file.pdf")

3. Daily, Take a Screenshot of Any Website

We will use Selenium to take a screenshot. Generally, Selenium is used for scraping data from any website. It’s a large library, and we are just used to taking screenshots. Now we need to install it.

pip install selenium

Just copy and run

from selenium import webdriver

def capture_screenshot(url, filename="screenshot.png"):
    options = webdriver.ChromeOptions()
    options.add_argument("--headless")
    driver = webdriver.Chrome(options=options)
    driver.get(url)
    driver.save_screenshot(filename)
    driver.quit()
#add url of any website which you want to take screenshot
capture_screenshot("https://www.bbc.com/news")

4. Convert YouTube Videos to MP3

Download YouTube videos and convert them to MP3.

pytube is a genuine, lightweight, dependency-free Python library for downloading YouTube videos.

pip install pytube
from pytube import YouTube
import os

def download_audio(url):
    yt = YouTube(url)
    stream = yt.streams.filter(only_audio=True).first()
    out_file = stream.download()
    base, ext = os.path.splitext(out_file)
    new_file = base + '.mp3'
    os.rename(out_file, new_file)

# download_audio("https://www.youtube.com/watch?v=your_video_id")

5. Auto Backup Important Files

Automatically back up a folder to another location.

import shutil
import datetime

def backup_folder(source, destination):
    date_str = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
    dest_path = os.path.join(destination, f"backup_{date_str}")
    shutil.copytree(source, dest_path)

# backup_folder("/path/to/source", "/path/to/backup")

6. Send WhatsApp Messages Automatically

Use pywhatkit to send WhatsApp messages.

pip install pywhatkit

This Python script automates sending WhatsApp messages using the Selenium WebDriver. Instead of using pywhatkit, it directly opens web.whatsapp.com, waits for the user to scan the QR code, navigates to the desired contact using their phone number, types the message, and sends it.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

def send_whatsapp_message(number, message):
    # Open browser and go to WhatsApp Web
    driver = webdriver.Chrome()  # Make sure chromedriver is in PATH
    driver.get("https://web.whatsapp.com")
    
    print("Scan the QR Code and press ENTER after login...")
    input()  # Wait for user to scan QR

    # Go to the chat by phone number
    driver.get(f"https://web.whatsapp.com/send?phone={number}&text={message}")
    time.sleep(10)  # Wait for chat to load

    # Press Enter to send the message
    input_box = driver.find_element(By.XPATH, '//div[@contenteditable="true"][@data-tab="10"]')
    input_box.send_keys(Keys.ENTER)

    print("Message sent!")
    time.sleep(5)
    driver.quit()

# Example usage
send_whatsapp_message("+911234567890", "Hello from Selenium!")

This approach offers more control and flexibility, especially useful when you want to:

  • Avoid third-party libraries like pywhatkit
  • Handle dynamic interactions on WhatsApp Web
  • Integrate with more complex workflows (e.g., chatbots, web scraping)

It mimics real user behavior and can be extended to:

  • Send attachments
  • Handle groups
  • Schedule future messages

⚠️ Note: You must be logged into WhatsApp Web for the script to work. This script is for educational and personal use only Avoid spamming.

7. Scrape Weather Updates

You need to install requests library to call api

pip install requests

Fetch real-time weather data from OpenWeatherMap. Sign up for openWeatherMap and verify your credit card for api 1000 api hit is free.

import requests

def get_weather(city):
    api_key = "your_api_key"
    url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
    data = requests.get(url).json()
    print(f"{city}: {data['main']['temp']}°C, {data['weather'][0]['description']}")

# get_weather("New Delhi")

8. Auto-Login to Websites

Use Selenium to log into websites automatically.

from selenium import webdriver

def login_site(url, username, password):
    driver = webdriver.Chrome()
    driver.get(url)
    driver.find_element("name", "username").send_keys(username)
    driver.find_element("name", "password").send_keys(password)
    driver.find_element("name", "submit").click()

# login_site("https://example.com/login", "your_user", "your_pass")

9. Text-to-Speech Bot

A Python library called pyttsx3 converts text to speech. It is compatible with Python 2 and 3, and unlike other libraries, it operates offline.

pip install pyttsx3

Turn your text into speech using pyttsx3.

import pyttsx3

def speak(text):
    engine = pyttsx3.init()
    engine.say(text)
    engine.runAndWait()

# speak("Good Morning! Time to start your day productively.")

10. Daily To-Do Notifier

Pop up your daily to-do list as a notification.

pip install plyer
from plyer import notification

def daily_todo():
    tasks = "- Check Emails\n- Standup Meeting\n- Work on Project"
    notification.notify(
        title="Today's To-Do",
        message=tasks,
        timeout=10
    )

# daily_todo()

Bonus Tip:

Set up cron jobs (Linux) or Task Scheduler (Windows) to run these scripts automatically every day!

If you found this helpful, share it with a fellow Python enthusiast. Have a favourite script of your own? Drop it in the comments below!

Leave a Comment

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

Scroll to Top