18 Mindblowing Python Automation Scripts I Use Everyday
— -
Discover 18 powerful Python automation scripts that can save you time every day. Learn how to automate tasks like file organization, web scraping, and more with Python.
— -
**Introduction**:
Python’s simplicity and versatility make it an ideal tool for automating repetitive tasks. Whether you’re managing files, scraping the web, or organizing data, Python can help you save time and streamline your workflow. In this article, I’ll share 18 Python automation scripts that I personally use on a daily basis.
— -
### **1. Bulk File Renaming Script**
Renaming multiple files one by one is tedious. With Python’s `os` and `glob` modules, you can create a script to bulk rename files in seconds. This is especially useful for organizing images or documents.
```python
import os
for count, filename in enumerate(os.listdir(“path/to/directory”)):
os.rename(filename, f”new_filename_{count}.ext”)
```
— -
### **2. Web Scraping with BeautifulSoup**
Need to pull data from websites regularly? Using Python’s BeautifulSoup library, you can scrape and extract information from web pages and save it to a file for later use.
```python
from bs4 import BeautifulSoup
import requests
url = “https://example.com"
response = requests.get(url)
soup = BeautifulSoup(response.text, ‘html.parser’)
data = soup.find_all(“div”, class_=”info”)
```
— -
### **3. Automated Email Sender**
Sending out emails manually can be time-consuming. With Python’s `smtplib`, you can automate the process of sending personalized emails.
```python
import smtplib
def send_email(to_address, subject, body):
server = smtplib.SMTP(‘smtp.gmail.com’, 587)
server.starttls()
server.login(“your_email@gmail.com”, “password”)
message = f”Subject: {subject}\n\n{body}”
server.sendmail(“your_email@gmail.com”, to_address, message)
server.quit()
```
— -
### **4. File Organizer Script**
Tired of having a messy desktop? Create a Python script that organizes files into folders based on their type.
```python
import os
import shutil
extensions = {“.jpg”: “Images”, “.pdf”: “Documents”, “.mp3”: “Music”}
for filename in os.listdir():
ext = os.path.splitext(filename)[1]
if ext in extensions:
shutil.move(filename, extensions[ext])
```
— -
### **5. Automate Social Media Posts**
You can automate posting content on social media platforms using Python’s `tweepy` for Twitter and `instabot` for Instagram.
```python
import tweepy
auth = tweepy.OAuthHandler(“API_KEY”, “API_SECRET”)
auth.set_access_token(“ACCESS_TOKEN”, “ACCESS_SECRET”)
api = tweepy.API(auth)
api.update_status(“Hello World! Automated Tweet!”)
```
— -
### **6. Convert PDF to Text**
Need to extract text from PDF documents? Python’s `PyPDF2` library makes it easy to convert PDFs into editable text files.
```python
import PyPDF2
with open(‘file.pdf’, ‘rb’) as pdf_file:
reader = PyPDF2.PdfFileReader(pdf_file)
for page in range(reader.numPages):
print(reader.getPage(page).extractText())
```
— -
### **7. Automate Backup Creation**
Create backups of important files and directories using Python’s `shutil` module. You can schedule it to run daily using a cron job or `Task Scheduler`.
```python
import shutil
shutil.make_archive(‘backup_folder’, ‘zip’, ‘path/to/folder’)
```
— -
### **8. Web Scraping for Job Listings**
Looking for a job? Automate scraping job listings from websites like LinkedIn or Indeed and organize the data for easy access.
```python
import requests
from bs4 import BeautifulSoup
url = “https://job_website.com/jobs"
response = requests.get(url)
soup = BeautifulSoup(response.text, ‘html.parser’)
jobs = soup.find_all(“h2”, class_=”job-title”)
```
— -
### **9. Currency Conversion Script**
Stay up to date with live currency exchange rates by automating currency conversions using Python’s `forex-python` library.
```python
from forex_python.converter import CurrencyRates
c = CurrencyRates()
print(c.convert(‘USD’, ‘EUR’, 100))
```
— -
### **10. Automate Data Entry**
Using Python’s `pyautogui`, you can automate filling out online forms or entering data into spreadsheets with ease.
```python
import pyautogui
pyautogui.write(“Hello World”)
pyautogui.press(“enter”)
```
— -
### **11. Weather Updates Script**
Stay updated with the latest weather reports by automating weather updates using Python’s `requests` module and an API like OpenWeatherMap.
```python
import requests
api_key = “your_api_key”
city = “London”
response = requests.get(f”http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}")
weather_data = response.json()
print(weather_data)
```
— -
### **12. YouTube Video Downloader**
Easily download your favorite YouTube videos using the `pytube` library.
```python
from pytube import YouTube
yt = YouTube(‘https://www.youtube.com/watch?v=example')
stream = yt.streams.get_highest_resolution()
stream.download()
```
— -
### **13. Password Generator**
Generate secure, random passwords in seconds using Python’s `random` and `string` modules.
```python
import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
return ‘’.join(random.choice(characters) for i in range(length))
print(generate_password(12))
```
— -
### **14. Website Status Checker**
Monitor your website’s uptime by automating a website status checker using Python’s `requests` module.
```python
import requests
def check_website(url):
response = requests.get(url)
return response.status_code
print(check_website(“https://www.example.com"))
```
— -
### **15. Instagram Photo Downloader**
Download photos from Instagram with Python using `instaloader`.
```python
import instaloader
loader = instaloader.Instaloader()
loader.download_profile(“instagram_username”, profile_pic_only=True)
```
— -
### **16. Automate Zoom Meetings**
Join Zoom meetings automatically by using Python’s `subprocess` module to open Zoom with the meeting link.
```python
import subprocess
subprocess.run([“open”, “zoommtg://zoom.us/join?action=join&confno=123456789”])
```
— -
### **17. Automate Text-to-Speech**
Convert text files to audio using Python’s `pyttsx3` library.
```python
import pyttsx3
engine = pyttsx3.init()
engine.say(“Hello World”)
engine.runAndWait()
```
— -
### **18. Automate Time Tracking**
Track your work hours automatically with Python’s `datetime` module.
```python
from datetime import datetime
start_time = datetime.now()
# Work code…
end_time = datetime.now()
print(f”Total time: {end_time — start_time}”)
```
— -
**Conclusion**:
Python’s versatility makes it the perfect tool for automating everyday tasks. From organizing files to sending emails and downloading videos, these Python scripts can save you hours of manual work. Whether you’re a beginner or an experienced coder, these automation scripts are sure to improve your workflow.
— -