Most "automation" is just a short script you run once a week. Here are three I use for tidying files and checking sites. They use only the Python standard library (3.8+), so there is nothing to install. Test them on a copy of a folder first.
1. Organize a folder by file type
Moves files into Images, Documents, Archives, Audio, Video, Code and Other. Run it with --dry-run first to see what would happen.
# 01_organize_folder.py """Sort files in a folder into subfolders by type. Usage: python 01_organize_folder.py FOLDER [--dry-run]""" import sys, shutil from pathlib import Path KINDS = {"Images": {".jpg",".jpeg",".png",".gif",".webp",".svg"}, "Documents": {".pdf",".doc",".docx",".txt",".xlsx",".csv",".pptx"}, "Archives": {".zip",".tar",".gz",".rar",".7z"}, "Audio": {".mp3",".wav",".m4a"}, "Video": {".mp4",".mkv",".mov"}, "Code": {".py",".js",".html",".css",".json"}} def main(): if len(sys.argv) < 2: sys.exit(__doc__) root, dry = Path(sys.argv[1]), "--dry-run" in sys.argv for f in sorted(root.iterdir()): if not f.is_file(): continue kind = next((k for k, ext in KINDS.items() if f.suffix.lower() in ext), "Other") dest = root / kind / f.name print(f"{f.name} -> {kind}/") if not dry: dest.parent.mkdir(exist_ok=True); shutil.move(str(f), str(dest)) if __name__ == "__main__": main() python 01_organize_folder.py ~/Downloads --dry-run python 01_organize_folder.py ~/Downloads 2. Find duplicate files by content
Two files are duplicates if their sizes and SHA-256 hashes match, regardless of name. The script only reports duplicates; it never deletes anything.
# 04_find_duplicate_files.py """Find duplicate files by content hash. Usage: python 04_find_duplicate_files.py FOLDER""" import sys, hashlib from pathlib import Path from collections import defaultdict def sha(p): h = hashlib.sha256() with open(p, "rb") as f: for chunk in iter(lambda: f.read(1 << 20), b""): h.update(chunk) return h.hexdigest() def main(): if len(sys.argv) < 2: sys.exit(__doc__) groups = defaultdict(list) for p in Path(sys.argv[1]).rglob("*"): if p.is_file(): groups[(p.stat().st_size, sha(p))].append(p) dups = [v for v in groups.values() if len(v) > 1] for g in dups: print("DUPLICATES:\n " + "\n ".join(map(str, g))) print(f"{len(dups)} duplicate group(s) found") if __name__ == "__main__": main() python 04_find_duplicate_files.py ~/Pictures 3. Check whether sites are up
# 06_site_status.py import sys, time, urllib.request for url in sys.argv[1:]: t = time.time() try: with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": "status-check/1.0"}), timeout=10) as r: print(f"UP {r.status} {(time.time()-t)*1000:6.0f} ms {url}") except Exception as e: print(f"DOWN {url} ({type(e).__name__}: {e})") python 06_site_status.py https://example.com https://example.org Only check sites you own or are allowed to test.
Tips for safe automation scripts
- Add a
--dry-runmode to anything that changes or deletes files. - Print what you are about to do before doing it.
- Never hard-code passwords or tokens; read them from environment variables.
- Start on a copy of your data.
- Keep scripts short so you can read them in a minute.
More
The three scripts above are free to copy from a page that also lists the rest of my set: https://luxury-malabi-8a7447.netlify.app/scripts.html . The full pack of ten (adds bulk rename, CSV dedupe, log summary, offline password audit, JSON to CSV, dated backups and a security-headers check) is here: https://yogeshwarantechtools.myinstamojo.com/product/python-automation-scripts-pack-10-ready-to-r
Written by Yogeshwaran Tech Tools. Corrections welcome.

