A script that sorts a messy downloads folder by type and date.
Welcome to the project module. Everything from here on works differently: no more lessons about things. Each lesson is one complete script that you build, run, verify and keep. And every project uses only ingredients you already own — variables, lists, loops, if, files, and the debugging calm from Module 3.
First up, the classic: a script that takes a chaotic folder full of files and sorts them into tidy subfolders by type. It is the "Hello, world!" of useful automation.
The plan in English first
Module 1 said the hardest part of programming is working out exactly what the task is. So before any code, the plan in plain English:
1Look at every file in a folder.
2Work out what kind of file each one is from its ending — .pdf, .jpg, .csv and so on.
3Make a subfolder for that kind, if one does not exist yet.
4Move the file in.
Four steps. A loop, a couple of new tools, done. That is the whole project.
🔒
Keep reading with Pro
You are reading the free preview. Module 1 of every course is free forever — Pro unlocks the rest of this lesson, every other module of every course, removes ads, and adds workbooks and certificates.