Sunday, 2 February 2025

18 Insanely Useful Python Automation Scripts I Use Everyday


 Here’s a list of 18 insanely useful Python automation scripts you can use daily to simplify tasks, improve productivity, and streamline your workflow:


1. Bulk File Renamer

Rename files in a folder based on a specific pattern.


import os
for i, file in enumerate(os.listdir("your_folder")):
os.rename(file, f"file_{i}.txt")

2. Email Sender

Send automated emails with attachments.


import smtplib
from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart msg = MIMEMultipart() msg['From'] = "you@example.com" msg['To'] = "receiver@example.com" msg['Subject'] = "Subject" msg.attach(MIMEText("Message body", 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls() server.login("you@example.com", "password") server.sendmail(msg['From'], msg['To'], msg.as_string())
server.quit()

3. Web Scraper

Extract useful data from websites.


import requests
from bs4 import BeautifulSoup url = "https://example.com" soup = BeautifulSoup(requests.get(url).text, 'html.parser')
print(soup.title.string)

4. Weather Notifier

Fetch daily weather updates.


import requests
city = "London" url = f"https://wttr.in/{city}?format=3"
print(requests.get(url).text)

5. Wi-Fi QR Code Generator

Generate QR codes for your Wi-Fi network.


from wifi_qrcode_generator import wifi_qrcode
wifi_qrcode("YourSSID", False, "WPA", "YourPassword").show()

6. YouTube Video Downloader

Download YouTube videos in seconds.


from pytube import YouTube
YouTube("video_url").streams.first().download()

7. Image Resizer

Resize multiple images at once.


from PIL import Image
Image.open("input.jpg").resize((500, 500)).save("output.jpg")

8. PDF Merger

Combine multiple PDFs into one.


from PyPDF2 import PdfMerger
merger = PdfMerger() for pdf in ["file1.pdf", "file2.pdf"]: merger.append(pdf)
merger.write("merged.pdf")

9. Expense Tracker

Log daily expenses in a CSV file.


import csv
with open("expenses.csv", "a") as file: writer = csv.writer(file)
writer.writerow(["Date", "Description", "Amount"])

10. Automated Screenshot Taker

Capture screenshots programmatically.


import pyautogui
pyautogui.screenshot("screenshot.png")

11. Folder Organizer

Sort files into folders by type.


import os, shutil
for file in os.listdir("folder_path"): ext = file.split('.')[-1] os.makedirs(ext, exist_ok=True)
shutil.move(file, ext)

12. System Resource Monitor

Check CPU and memory usage.

import psutil
print(f"CPU: {psutil.cpu_percent()}%, Memory: {psutil.virtual_memory().percent}%")

13. Task Scheduler

Automate repetitive tasks with schedule.


import schedule, time
schedule.every().day.at("10:00").do(lambda: print("Task executed")) while True:
schedule.run_pending()
time.sleep(1)

14. Network Speed Test

Measure internet speed.


from pyspeedtest import SpeedTest
st = SpeedTest()
print(f"Ping: {st.ping()}, Download: {st.download()}")

15. Text-to-Speech Converter

Turn text into audio.


import pyttsx3
engine = pyttsx3.init() engine.say("Hello, world!")
engine.runAndWait()

16. Password Generator

Create secure passwords.


import random, string
print(''.join(random.choices(string.ascii_letters + string.digits, k=12)))

17. Currency Converter

Convert currencies with real-time rates.

import requests
url = "https://api.exchangerate-api.com/v4/latest/USD" rates = requests.get(url).json()["rates"]
print(f"USD to INR: {rates['INR']}")

18. Automated Reminder

Pop up reminders at specific times.


from plyer import notification
notification.notify(title="Reminder", message="Take a break!", timeout=10)

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (96) AI (38) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (186) C (77) C# (12) C++ (83) Course (67) Coursera (246) Cybersecurity (25) Data Analysis (1) Data Analytics (2) data management (11) Data Science (140) Data Strucures (8) Deep Learning (21) Django (14) Downloads (3) edx (2) Engineering (14) Euron (26) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Generative AI (7) Google (34) Hadoop (3) HTML Quiz (1) HTML&CSS (47) IBM (30) IoT (1) IS (25) Java (93) Java quiz (1) Leet Code (4) Machine Learning (76) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (4) Pandas (4) PHP (20) Projects (29) Python (990) Python Coding Challenge (428) Python Quiz (67) Python Tips (3) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (4) Software (17) SQL (42) UX Research (1) web application (8) Web development (4) web scraping (2)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses

Python Coding for Kids ( Free Demo for Everyone)