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!
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/
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:
$ 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.