Home Command line utilities How To Automatically Organize Similar Type Of Files In Specific Folders

How To Automatically Organize Similar Type Of Files In Specific Folders

By sk
Published: Last Updated on 2.8K views

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!

Install Classifier

Since it is written using python language, we can easily install it using pip, a python package manager.

On Arch Linux and its derivatives, run the following command to install pip:

$ sudo pacman -S python-pip

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install python-pip

On RHEL, Fedora, CentOS:

$ sudo yum install python-pip


$ sudo dnf install python-pip


$ sudo zypper install python-pip

After installing PIP, run the following command to install Classifier.

$ sudo pip install classifier

Sample output would be:

 Collecting classifier
 Downloading classifier-1.7.tar.gz
 Collecting arrow (from classifier)
 Downloading arrow-0.10.0.tar.gz (86kB)
 100% |████████████████████████████████| 92kB 250kB/s
 Requirement already satisfied: six>=1.10.0 in /usr/lib/python3.6/site-packages (from classifier)
 Collecting python-dateutil (from arrow->classifier)
 Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
 100% |████████████████████████████████| 194kB 389kB/s
 Installing collected packages: python-dateutil, arrow, classifier
 Running setup.py install for arrow ... done
 Running setup.py install for classifier ... done
 Successfully installed arrow-0.10.0 classifier-1.7 python-dateutil-2.6.0

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

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:

$ classifier -st .jpg -sf "Images"

Here, -st indicates specific file types and -sf indicates specific folder.

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.



Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like


Claude March 18, 2017 - 4:13 am

What are the theme and icons you are using ? And on what desktop ?

SK March 18, 2017 - 12:13 pm

I use Arch Linux with Deepin Desktop Environment. Also, I use MATE desktop sometimes.

Dan St.André March 19, 2017 - 1:27 am

Its intuitive that SPECIFIC_TYPES refer to the “file type” from the file name. The –help gives no details about where these files will go if a SPECIFIC_FOLDER is not named.

Also, it would be nice if one got a report or histogram of the various file types that appear in the folder getting processed.

Also, it might be nice if one could name a target folder, eg, ~/myClassified, where all processed folders get created and the classified files get copied.

Dan St.André March 20, 2017 - 12:27 am

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.

Thanks for the article,
~~~ 0;-Dan
Austin, TX USA


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More