Skip to main content

10 Practical Python Automation Scripts

·595 words·3 mins
Python Automation Scripts Productivity
Table of Contents

Repetitive tasks often waste valuable time and energy — cropping 100 photos, fetching API data, fixing spelling mistakes, and so on. Why not let Python automation handle them for you?

In this post, we’ll explore 10 practical Python automation scripts you can use right away to boost your productivity.

1. Image Optimizer
#

With the Pillow module, you can crop, resize, rotate, compress, blur, sharpen, adjust brightness/contrast, and even add filters.

# pip install Pillow
import PIL
# Crop
im = PIL.Image.open("Image1.jpg")
im = im.crop((34, 23, 100, 100))
# Resize
im = im.resize((50, 50))
# Flip
im = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
# Rotate
im = im.rotate(360)
# Compress
im.save("Image1.jpg", optimize=True, quality=90)
# Blur
im = im.filter(PIL.ImageFilter.BLUR)
# Sharpen
im = im.filter(PIL.ImageFilter.SHARPEN)
# Brightness
im = PIL.ImageEnhance.Brightness(im).enhance(1.5)
# Contrast
im = PIL.ImageEnhance.Contrast(im).enhance(1.5)
# Filters
im = PIL.ImageOps.grayscale(im)
im = PIL.ImageOps.invert(im)
im = PIL.ImageOps.posterize(im, 4)
# Save
im.save("Image1.jpg")

2. Video Optimizer
#

Use MoviePy to cut, merge, speed up, add effects, or attach background audio.

# pip install moviepy
import moviepy.editor as pyedit
video = pyedit.VideoFileClip("vid.mp4")
# Cut segments
vid1 = video.subclip(0, 10)
vid2 = video.subclip(20, 40)
final_vid = pyedit.concatenate_videoclips([vid1, vid2])
# Speed up
final_vid = final_vid.speedx(2)
# Add audio
aud = pyedit.AudioFileClip("bg.mp3")
final_vid = final_vid.set_audio(aud)
# Reverse video
final_vid = final_vid.fx(pyedit.vfx.time_mirror)
# Save
final_vid.write_videofile("final.mp4")

3. PDF to Images
#

Convert each page of a PDF into PNG images with PyMuPDF.

# pip install PyMuPDF
import fitz
def pdf_to_images(pdf_file):
    doc = fitz.open(pdf_file)
    for p in doc:
        pix = p.get_pixmap()
        pix.writePNG(f"page{p.number}.png")
pdf_to_images("test.pdf")

4. Fetch API Data
#

Use urllib3 to perform GET and POST requests easily.

# pip install urllib3
import urllib3
url = "https://api.github.com/users/psf/repos"
http = urllib3.PoolManager()
response = http.request('GET', url)
print(response.status, response.data)

url = "https://httpbin.org/post"
response = http.request('POST', url, fields={'hello': 'world'})
print(response.status)

5. Battery Level Reminder
#

Show a desktop notification when your laptop battery drops below a certain threshold.

# pip install plyer psutil
from plyer import notification
import psutil, time

while True:
    battery = psutil.sensors_battery()
    if battery.percent < 50:
        notification.notify(
            title="Low Battery",
            message="Please connect the charger",
            timeout=10
        )
    time.sleep(60)

6. Grammar Corrector
#

Fix grammar errors in text using HappyTransformer.

# pip install happytransformer
from happytransformer import HappyTextToText, TTSettings

def grammar_fixer(text):
    model = HappyTextToText("T5", "prithivida/grammar_error_correcter_v1")
    config = TTSettings(do_sample=True, top_k=10, max_length=100)
    result = model.generate_text(text, args=config)
    print("Corrected:", result.text)

grammar_fixer("This is smple tet we how know this")

7. Spelling Corrector
#

Use TextBlob to correct spelling in words or full paragraphs.

# pip install textblob
from textblob import TextBlob, Word

def fix_paragraph_words(text):
    print(TextBlob(text).correct())

def fix_word_spell(word):
    print(Word(word).correct())

fix_paragraph_words("This is sammple tet!!")
fix_word_spell("maangoo")

8. Internet Downloader
#

Download files with resume support using the IDM module.

# pip install internetdownloadmanager
import internetdownloadmanager as idm

def Downloader(url, output):
    d = idm.Downloader(worker=20, part_size=1024*1024*10, resumable=True)
    d.download(url, output)

Downloader("https://example.com/image.jpg", "image.jpg")
Downloader("https://example.com/video.mp4", "video.mp4")

9. World News Fetcher
#

Get real-time global news via the World News API.

# pip install requests
import requests
ApiKey = "YOUR_API_KEY"
url = f"https://api.worldnewsapi.com/search-news?text=hurricane&api-key={ApiKey}"
response = requests.get(url, headers={'Accept': 'application/json'})
print("News:", response.json())

10. GUI App with PySide
#

Build a simple cross-platform desktop app using PySide.

# pip install PySide6
from PySide6.QtWidgets import *
import sys

app = QApplication(sys.argv)
window = QWidget()
window.resize(500, 500)
window.setWindowTitle("PySide App")

QPushButton("Click Me", window).move(200, 200)
QLabel("Hello World", window).move(200, 150)

window.show()
sys.exit(app.exec())

✅ Final Thoughts
#

These 10 Python automation scripts cover everything from image and video processing to API integration, grammar correction, news fetching, and GUI development.

Start small, integrate them into your workflow, and you’ll soon discover how much time and effort Python automation can save you.

Don’t forget to bookmark this article — automation is one of the most valuable skills in today’s IT industry.

Related

20 Essential Docker Container Script Commands
·650 words·4 mins
Docker Script DevOps Automation
9 Practical Python Examples You Can Use Today
·403 words·2 mins
Python Examples Tutorial
Intel’s Inventor of the Year Joins Samsung to Lead Advanced Packaging
·623 words·3 mins
Intel Samsung Advanced Packaging Glass Substrate EMIB Semiconductor Talent