Python Files Categorizer

Aslam Anver
Nov 1, 2020

Categorize the files by year and month as folders

before categorize

I came across an incident that there is a screenshot directory that contains more than 4000 high-quality images, when I open the screenshots folder every time the system hangs even sometimes it freezes too. So I needed to find a solution to categorize all of my images into folders even it’s not possible by just cut and paste through file explorers.

I needed to move an image to a folder named the year and month from the image’s created date also at the end of this categorization I needed to mention the files count of the categorized directory as part of its name.

Example: apple.png, orange.png images are created at 2020–10–10 and I need to move both images to a folder named 2020–10_2 that year-month_files-count

Eventually, I wrote a script in Python to achieve this solution in a few seconds.

This script can be executed by any of you by a single line of command.

python categorizer.py /home/aslam/screenshots

That’s it, now your directory looks so clean and performance-friendly.

after categorize

Thank you for reading✌️ I’m Aslam Anver find me on GitHub and StackOverflow as aslamanver & Googlian

--

--

Aslam Anver

Passionate in AI Deep Learning, Find me on GitHub & StackOverflow