Automate a repetitive computer task with Python
Three hour-long sessions built on the free online Automate the Boring Stuff book and the official Python docs. You'll practice on a safe test folder, then finish with a script that renames and sorts a real messy folder and logs every change.
Outcome
A reusable tidy.py that previews changes, gives every file a clean dated name, sorts files into folders by type, never overwrites or deletes, and writes a log.
- Every resource is a real public page our team picked. Our server checks the links; if one ever breaks, tell us and we'll replace it.
- Always work on a copy of a real folder first, and always do a dry run. A script can move hundreds of files in a second, and mistakes are fast too.
- This journey never deletes files. Don't add deleting until you've read the safe-deleting section of chapter 11.
- Don't run it on system folders, app folders, or cloud-synced folders until you've tested on a copy; moving files there can break apps or sync.
- 10,000 seconds is a structured starting point. It builds a real first result, not guaranteed expertise.
Outline
- 155:34
Build a safe practice folder and survey it
You have a practice folder of messy files and a script that lists and counts them by type.
- 255:33
Sort files into folders, with a dry run first
A script that previews moving each file into Images, Documents, Audio, or Other, then does it for real.
- 355:33
Capstone: rename and organize in one run
A finished script that gives every file a clean, dated name, sorts it into a folder, and writes a log of what it did.
Capstone
Your file tidying tool
A Python script that previews and then renames and sorts a folder of files into type folders with clean, dated names, protects against overwriting, and logs every change, tested on a copy of a real folder.
Sources
- Chapter 11: Organizing Files
Automate the Boring Stuff with Python, 3rd Edition (Al Sweigart)
Not yet verifiedFree - Chapter 10: Reading and Writing Files
Automate the Boring Stuff with Python, 3rd Edition (Al Sweigart)
Not yet verifiedFree - pathlib: Object-oriented filesystem paths
Python Software Foundation (official docs)
Not yet verifiedFree - shutil: High-level file operations
Python Software Foundation (official docs)
Not yet verifiedFree