DEV Community

Cover image for Declutter your Downloads folder with Python 😎
Aahnik Daw
Aahnik Daw

Posted on • Updated on

Declutter your Downloads folder with Python 😎

Introduction

We download tons of files daily from the internet.

If you are a Windows user, they most probably land up in your Desktop folder by default, making it look like a mess.

For Unix users, it's generally the ~/Downloads folder.

Having all the files in one folder makes it hard to navigate. It takes more time to reach the desired file. And it simply looks bad.

One great way of organizing files is by their mime type. That is, all the images go to one folder, all the pdfs to another, and so on.

So I made a simple tool, that can declutter your downloads folder.

dirganize

How to install?

Make sure you have python and pip installed in your system.

The package dirganize is published to the Python Package Index. So, why wait, you can easily install it with a single pip command.

❯ pip install dirganize
Enter fullscreen mode Exit fullscreen mode

How to use ?

Navigate into the directory, which you want to organize, and run the dirganize command.

cd Downloads
❯ dirganize
Creating mapping  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Moving files  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00

Enter fullscreen mode Exit fullscreen mode

And that's it. Your folder is organized.

Run the ls command (or dir for Windows) before and after executing dirganize to see the magic.

alt text

Your rules

Your folder. Your rules.

Want to change the rules? I mean the rules that govern which file goes to which folder.

Then simply, put a .dirganize.yml file inside the folder to override the default configuration.

A yaml file is basically converted to a python dictionary by dirganize. The default dictionary is overwritten by the user-defined configuration (when available).

I am Aahnik Daw and you can follow me on GitHub and dev.to to stay updated with my latest repos and articles.

Top comments (1)

Collapse
 
phase_seven profile image
Ratul Roy

Amazing work. Try integrating TOML files instead of YAML.