Letβs be honest:
My desktop was a digital jungle β screenshots, PDFs, memes, random .zip files from 2019...
So I did what any lazy but efficient developer would do:
I built a Python script that automatically organizes my desktop every night at 11:59 PM.
It sorts files into folders like Images, Docs, Zips, etc.
Now, my desktop stays clean, and I donβt lift a finger. π
π§ How It Works
The script scans your desktop.
It looks at file extensions.
It moves files into categorized folders.
It can run every night using a scheduled task (Windows Task Scheduler / cron on macOS/Linux).
π The Python Code:
import os
import shutil
from pathlib import Path
# Set your desktop path
desktop = Path.home() / "Desktop"
# File categories
categories = {
"Images": [".jpg", ".jpeg", ".png", ".gif"],
"Documents": [".pdf", ".docx", ".txt"],
"Zips": [".zip", ".rar"],
"Code": [".py", ".js", ".html"],
"Videos": [".mp4", ".mov"],
"Others": []
}
def organize():
for file in desktop.iterdir():
if file.is_file():
moved = False
for folder, extensions in categories.items():
if file.suffix.lower() in extensions:
move_file(file, desktop / folder)
moved = True
break
if not moved:
move_file(file, desktop / "Others")
def move_file(file, destination):
destination.mkdir(exist_ok=True)
shutil.move(str(file), str(destination / file.name))
print(f"Moved: {file.name} β {destination}")
if __name__ == "__main__":
organize()
π How to Run It Automatically
πͺ Windows:
Open Task Scheduler.
Create a new task.
Set a daily trigger (e.g., 11:59 PM)
Action:
Program/script: python
Add arguments: C:\path\to\desktop_organizer.py
π macOS/Linux:
Add this to your crontab:
59 23 * * * /usr/bin/python3 /path/to/desktop_organizer.py
πΎ GitHub Repo:
Nish2005karsh
π The Result?
Every night my desktop gets cleaned like magic β no guilt, no manual work.
Lazy? Maybe.
Efficient? Definitely.
π¬ What Should I Build Next?
Got a cool automation idea?
Want this to also auto-delete screenshots or organize by date?
Drop it in the comments π and Iβll try building it next!
Top comments (15)
Been meaning to do this forever honestly, helps keep me from losing stuff every week.
ACT prep improves time management, accuracy, and content knowledge. High ACT scores can significantly boost college admission chances.
This is a great idea! Youβve organized everything in your repository really well.
Since youβve grouped these functions together, you could start turning them into a series. Each post can focus on one script, explaining what it does, how it works, and where it can be useful. This will help others understand your work more easily and also serve as a good way to document your progress.
Creating a series also means people can find everything in one place instead of having to search through different posts.
Thank you so much for the kind words and valuable feedback! I really appreciate it.
Turning these into a series sounds like a fantastic idea β itβll definitely make the content easier to digest and more helpful for readers who want to dive deeper into each script. Plus, documenting my progress that way will keep me motivated and organized.
Iβll start working on breaking down the scripts into focused posts soon. Looking forward to sharing more and getting feedback along the way!
Thanks again for the encouragement! π
Love this! I could really use an auto-archiver that moves stuff to cloud if it hasn't been opened for months - have you thought about adding that feature?
Thank you! .Thatβs a brilliant ideaβadding a cloud-based auto-archiving feature for inactive files would definitely level up the utility of this project. Iβve been thinking about integrating something like that using platforms like Google Drive or Dropbox via their APIs. Maybe it could scan for files untouched for, say, 90 days and then zip + upload them.
Iβll definitely consider this for the next version. Thanks again for the suggestionβreally appreciate it!
Great idea! Helps with organizing without hassle. Thanks!
Thanks so much, Abhinav! π That was exactly the goalβset it and forget it. Glad you found it helpful! Let me know if you end up tweaking it or adding features π
Amazing growth π―π
Thanks so much, Melody! π Itβs been a fun journey automating little tasks like this. Excited to keep building and sharing more!
Amazing software
Thanks !!π
Love your idea, would definitely use it out of respect if i used a DE, but sorry i use Windows Managers π
Haha, totally fair! WM users are built different ππͺ. I respect the minimalist grindβmaybe one day Iβll cook up a WM-friendly version too. Appreciate the love either way!
This is really interesting stuff! Definitely useful when it comes to organizing things, it's a common problem. It would be interesting to learn how the program works and how it syncs with cloud storage services like OneDrive, Google Drive, or Dropbox!