How to Automate Everyday Tasks with Python

andreasPython Code3 weeks ago24 Views

Python isn’t just for developers — it’s a powerful tool for saving time by automating repetitive work.
Whether you’re renaming hundreds of files, sending emails, or grabbing images from the web, Python can do it for you in just a few lines of code.

Here are three practical scripts you can start using today.


1. Rename Multiple Files in a Folder

If you have a folder full of messy filenames, this script can rename them in a clean, consistent way.

import os

folder = "C:/path/to/folder"

for count, filename in enumerate(os.listdir(folder), start=1):
    ext = os.path.splitext(filename)[1]
    new_name = f"file_{count}{ext}"
    os.rename(os.path.join(folder, filename),
              os.path.join(folder, new_name))

print("Files renamed successfully!")

How it works:

  • Loops through every file in the folder
  • Assigns a new name with a number (file_1.jpg, file_2.jpg, etc.)

2. Send an Email Automatically

You can use Python to send an email (via Gmail in this example).

import smtplib
from email.mime.text import MIMEText

# Email settings
sender = "youremail@gmail.com"
receiver = "recipient@example.com"
password = "yourpassword"

# Email content
msg = MIMEText("Hello! This email was sent with Python.")
msg["Subject"] = "Automated Email"
msg["From"] = sender
msg["To"] = receiver

# Send email
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
    server.login(sender, password)
    server.send_message(msg)

print("Email sent!")

Important:

  • For Gmail, you may need to enable App Passwords instead of your real password.
  • Don’t hardcode credentials — use environment variables or a .env file.

3. Download an Image from the Internet

Need to grab a picture from a URL? Python can fetch and save it locally.

import requests

url = "https://example.com/image.jpg"
response = requests.get(url)

with open("downloaded_image.jpg", "wb") as file:
    file.write(response.content)

print("Image downloaded successfully!")

How it works:

  • Uses requests to fetch the image
  • Saves it as a file on your computer

Going Further

These examples just scratch the surface.
With Python, you can also:

  • Scrape websites for news, prices, or data
  • Convert PDFs to text automatically
  • Organize photos by date taken
  • Monitor websites for changes and send alerts

Conclusion

Automation with Python can save hours of manual work every week.
Start small — try one script — and you’ll quickly see how much easier your daily workflow becomes.

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Loading Next Post...
Loading

Signing-in 3 seconds...