Classifier – Tool to organize files in your directory instantly

I recently stumbled upon about Classifier app, which automatically organize files in your current directory, by classifying them into folders of Xls, Docs, .png, .jpeg, vidoe, music, pdfs, images, ISO, etc.

If I’m not wrong, all our download folder is pretty Sloppy compare with others because most of the downloaded files are sitting over there and we can’t delete blindly, which leads to lose some important files. Also not possible to create bunch of folders based on the files and move appropriate files into folder manually.

So, How to avoid this ? Better to organize files with help of classifier, later we can delete unnecessary files easily. Classifier app is written in Python.

How to Organize directory ? Simply navigate to corresponding directory, where you want to organize/classify your files and run the classifier command, it will take few mins or more depends on the directory files count or quantity.

Make a note, there is no undo option, if you want to go back. So, finalize before run classifier in directory. Also, it wont move folders.

Installing Classifier in Linux through pip :

pip is a recommended tool for installing Python packages in Linux. Use pip command instead of package manager to get latest build.

For Debian based systems.

$ sudo apt-get install python-pip

For RHEL/CentOS based systems.

$ sudo yum install python-pip

For Fedora

$ sudo dnf install python-pip

For openSUSE

$ sudo zypper install python-pip

For Arch Linux based systems

$ sudo pacman -S python-pip

Finally run the pip tool to install Classifier on Linux.

$ sudo pip install classifier

Organizing pattern files into specific folders :

First I will go with default option which will organize pattern files into specific folders. This will create bunch of directories based on the file types and move them into specific folders.

See my directory, how its looking now (Before run classifier command).

$ pwd
/home/magi/classifier

$ ls -lh
total 139M
-rw-r--r-- 1 magi magi 4.5M Mar 21 21:21 Aaluma_Doluma.mp3
-rw-r--r-- 1 magi magi  26K Mar 21 21:12 battery-monitor_0.4-xenial_all.deb
-rw-r--r-- 1 magi magi  24K Mar 21 21:12 buku-command-line-bookmark-manager-linux.png
-rw-r--r-- 1 magi magi    0 Mar 21 21:43 config.php
-rw-r--r-- 1 magi magi   25 Mar 21 21:13 core.py
-rw-r--r-- 1 magi magi 101K Mar 21 21:12 drawing.svg
-rw-r--r-- 1 magi magi  86M Mar 21 21:12 go1.8.linux-amd64.tar.gz
-rw-r--r-- 1 magi magi   28 Mar 21 21:13 index.html
-rw-r--r-- 1 magi magi   27 Mar 21 21:13 index.php
-rw-r--r-- 1 magi magi  48M Apr 30  2016 Kabali Tamil Movie _ Official Teaser _ Rajinikanth _ Radhika Apte _ Pa Ranjith-9mdJV5-eias.webm
-rw-r--r-- 1 magi magi   28 Mar 21 21:12 magi1.txt
-rw-r--r-- 1 magi magi   66 Mar 21 21:12 ppa.py
-rw-r--r-- 1 magi magi 1.1K Mar 21 21:12 Release.html
-rw-r--r-- 1 magi magi  45K Mar 21 21:12 v0.4.zip

Navigate to corresponding directory where you want to organize files, then run classifier command without any option to achieve it.

$ classifier
Scanning Files
Done!

See the Directory look, after run classifier command

$ ls -lh
total 44K
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Archives
-rw-r--r-- 1 magi magi    0 Mar 21 21:43 config.php
-rw-r--r-- 1 magi magi   25 Mar 21 21:13 core.py
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 DEBPackages
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Documents
-rw-r--r-- 1 magi magi   28 Mar 21 21:13 index.html
-rw-r--r-- 1 magi magi   27 Mar 21 21:13 index.php
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Music
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Pictures
-rw-r--r-- 1 magi magi   66 Mar 21 21:12 ppa.py
-rw-r--r-- 1 magi magi 1.1K Mar 21 21:12 Release.html
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Videos

Make a note, this will organize only general category files such as docs, audio, video, pictures, archive, etc and wont organize .py, .html, .php, etc.,.

Classify specific file types into specific folder

To Classify specific file types into specific folder, just add -st (mention the file type) & -sf (folder name) followed by classifier command.

For best understanding, I’m going to move .py, .html & .php files into Development folder. See the exact command to achieve it.

$ classifier -st .py .html .php -sf "Development" 
Scanning Files
Done!

If the folder doesn’t exit, it will create the new one and organize the files into that. See the following output. It created Development directory and moved all the files inside the directory.

$ ls -lh
total 28K
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Archives
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 DEBPackages
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:51 Development
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Documents
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Music
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Pictures
drwxr-xr-x 2 magi magi 4.0K Mar 21 21:28 Videos

For better clarification, i have listed Development folder files.

$ ls -lh Development/
total 12K
-rw-r--r-- 1 magi magi  0 Mar 21 21:43 config.php
-rw-r--r-- 1 magi magi 25 Mar 21 21:13 core.py
-rw-r--r-- 1 magi magi 28 Mar 21 21:13 index.html
-rw-r--r-- 1 magi magi 27 Mar 21 21:13 index.php
-rw-r--r-- 1 magi magi  0 Mar 21 21:43 ppa.py
-rw-r--r-- 1 magi magi  0 Mar 21 21:43 Release.html

To Organize files by Date. It will organize current directory files based on the date.

$ classifier -dt

To save organized files in different location, add -d (source directory) & -o (destination directory) followed by classifier command.

$  classifier -d /home/magi/organizer -o /home/magi/2g

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

Leave a Reply

Your email address will not be published. Required fields are marked *