Python felt like a superpower the primary time I used it to automate one thing boring. Not like different languages, Python’s syntax is easy and human-friendly. I didn’t want to consider varieties or construction — simply the logic.
My purpose? Automate all the pieces repetitive in my digital workflow — from cleansing up downloaded recordsdata to monitoring net modifications and sending Slack alerts.
Each morning, my Downloads folder was a multitude. PDFs, ZIPs, screenshots — everywhere. So I wrote this:
importos,shutil
src=os.path.expanduser('~/Downloads')
dsts={'pdf':'~/Paperwork/PDFs','zip':'~/Paperwork/Zips','png':'~/Footage/Screenshots'}
forfinos.listdir(src):
e=os.path.splitext(f)[1][1:]
ifeindsts:
shutil.transfer(os.path.be part of(src,f),os.path.expanduser(dsts[e]))
No extra muddle. Recordsdata now self-sort into folders by kind.
I needed to know the second a brand new weblog put up dropped on my favourite web site. So I used…