How To Automatically Organize Similar Type Of Files In Specific Folders

I always love to keep my Linux desktop well organized. I have created separate folders for each file types and saved them in the respective folders. I have a folder named ‘Entertainment’ to store my movies, videos, and audio files. A folder called ‘Official’ contains all my work related stuffs. ‘Personal’ folder contains my photos, documents etc. ‘Software’ folder contains all sort of software stuffs like OS images, applications. I hope everyone like to organize their stuffs as well. For those who are too lazy to organize their stuffs and keeping all type of files and folders in a common folder, there is a command line called “Classifier” can help you.

Classifier is simple python script that will automatically organize your files based on the file extension to different directories. Say for example, it will automatically create a directory called Audio and move all mp3 files in it. Similarly, It moves all zip/tar files to a folder called Archive, films to a folder called Videos and so on. You don’t need to manually create folders and move the files to the respective folders. Just install and run this utility, it will take care of everything. To put this simply, Classifier organizes files in your directory instantly, by classifying them into different folders. Sounds useful, isn’t it? Indeed!

Automatically Organize Similar Type Of Files In Specific Folders Using Classifier

After installing Classifier, go to the directory where you have your files, and run the ‘classifier’ command to organize them automatically, and move them to different folders based on the file extension.

Look at the following screenshot. I have a folder named “test” with different type of files.

As you see in the above directory, there are different type of files, such as Zip, ISO, Mp4, Doc, ODt, Xls, JPG etc. Instead of creating folders for each file type, go to this directory (i.e test in our case) and run ‘classifier’ command to organize them automatically in different folders.

$ cd test/

$ classifier

You will see output something like below.

Scanning Files
Done!

Your files have been organized in separate folders. Now, go and check the ‘test’ folder. You will see the difference.

As you see in the above screenshot, Classifier has created different directories for each file types and moved them into the respective folders automatically.

You can also classify files of a one directory, and save them in other location. The following command classifies the files of a folder /home/sk/Downloads/, and save them in a folder called /home/sk/ostechnix.

$ classifier -d /home/sk/Downloads -o /home/sk/ostechnix

Please note that Classifier organizes and moves files only, not directories. And also, you should be careful as there is no undo option.

You can also classify files based on their creation date.

$ classifier -dt

To classify specific file types, for example .jpg files, run the following command:

The above command will classify the .jpg files and save them in a folder called “Images”.

For more details, check Classifier help section by running the following command:

$ classifier -h

Classifier is indeed a brilliant script that find and organize different type files to specific folders automatically. If you have large number of different type of files in a directory, It will dramatically reduces the time to organize them.

That’s all for now folks. I will be soon here with another useful guide. If you find this guide useful, please share it on your social, professional networks and support OSTechNix.

Your title, “How to Automatically …” lead me to expect that I would learn how to cause ‘classifier’ to run whenever I added files into a folder or connected a USB stick or drive. Sadly, the article did not make any mention of “automaticaly” doing anything.

I did find ‘classifier’ useful and interesting and will likely find ways to deployit on my writer’s laptop.