DEV Community

Cover image for I got tired of my messy Downloads folder, so I automated it with Python!
Radhesh Kumar
Radhesh Kumar

Posted on

I got tired of my messy Downloads folder, so I automated it with Python!

Let's be honest our Downloads folder is a disaster zone. Mine definitely was.

Between downloading reference images, PDFs for class, random ZIP archives, and a dozen different .exe installers, it had become a massive dumping ground. I got tired of manually sorting it every month, so I spent an afternoon writing a lightweight Python script to do the heavy lifting for me.

The Logic

The idea is simple: scan the directory, check the file extensions, and instantly move them into categorized sub-folders.

I set up a dictionary mapping to handle all the standard file types:

EXTENSION_MAP = {
    "Images":       [".jpg", ".jpeg", ".png", ".gif", ".svg", ".webp", ".bmp"],
    "PDFs":         [".pdf"],
    "Installers":   [".exe", ".msi", ".dmg", ".pkg", ".deb", ".iso"],
    "Archives":     [".zip", ".rar", ".7z", ".tar", ".gz"],
    "Code":         [".py", ".js", ".html", ".css", ".java", ".cpp", ".json"]
    # ... and a few other categories
}
Enter fullscreen mode Exit fullscreen mode

Using Python's os and shutil libraries, the script just loops through the folder, checks the map, creates the directory if it doesn't exist, and moves the file. Boom. Instant organization.

The Code (Open Source)

If you want to read the raw code, tweak the extension mapping for your own workflow, or run it yourself, I made the repository fully public.

Check out the source code here: https://github.com/Radhesh20/digital-janitor

The "I'm Too Lazy to Run Python" Version

I know a lot of people don't want to mess with setting up Python environments or running scripts from the terminal just to clean their computer.

So, I used PyInstaller to compile the script into a standalone, 1-click Windows executable. You just double-click it, and your folder cleans itself instantly.

You can grab the .exe for free (Pay-What-You-Want) on my Gumroad:

Download the 1-Click App Here: https://radheshk.gumroad.com/l/digitaljanitor

Let me know if you guys think I should add any specific edge-case file extensions to the mapping!

Top comments (0)