Ubuntu / Linux news and application reviews.

My downloads folder is pretty messy but I can't just delete things because I still need most of the stuff I download. To "fix" this, I was looking for an app that can automatically organize my downloads, and I stumbled upon Classifier, an easy to use command line tool that can organize files in any directory.

Here's an example - on the left there's a folder which contains various file types (images, archives, documents, etc.) and on the right it's a folder that contains the exact same files as the folder on the left, but after running Classifier to organize it (into folders):

classifier organize folder

Classifier organizes a directory based on file extension, moving the files into specific folders, like music, documents, images and so on.

I should also note that while this article mentions organizing the downloads folder, Classifier can be used to organize files in any any directory.

To organize files in the downloads (~/Downloads) folder, either run Classifier in that folder with no arguments, e.g.:
cd ~/Downloads
Or specify the directory as an argument, like this:
classifier -d ~/Downloads

Classifier can also organize specific file types that aren't classified by default, organize by creation date and more. You can find a few examples on its GitHub page.

Here are all Classifier options:
$ classifier --help
usage: classifier [-h] [-st SPECIFIC_TYPES [SPECIFIC_TYPES ...]]
                  [-sf SPECIFIC_FOLDER] [-o OUTPUT] [-d DIRECTORY] [-dt]

Organize files in your directory instantly,by classifying them into different

optional arguments:
  -h, --help            show this help message and exit
                        Move all file extensions, given in the args list, in
                        the current directory into the Specific Folder
  -sf SPECIFIC_FOLDER, --specific-folder SPECIFIC_FOLDER
                        Folder to move Specific File Type
  -o OUTPUT, --output OUTPUT
                        Main directory to put organized folders
  -d DIRECTORY, --directory DIRECTORY
                        The directory whose files to classify
  -dt, --date           Organize files by creation date

Since the tool organizes files only when it's ran, and you may not want to run it manually every day / hour, etc., you can create a cron job to run it periodically. For those who are not very familiar with Cron, here's an online crontab generator (use the full path to the classifier executable in the crontab if you install it using the instructions in this article).

Important: Classifier doesn't display any warning or confirmation when moving files, and there's no way to undo any operations it performs, so make sure you run it in the correct folder and / or with the correct arguments!

Tip: for a somewhat similar tool which doesn't organize folders based on file types, but based on when the files were last accessed, check out Download Sweeper.

Install Classifier

1. Classifier can be installed using Python pip (you'll also need python-setuptools). To install python-pip and python-setuptools in Ubuntu, Debian, Linux Mint and other Debian-based Linux distributions, use the following command:
sudo apt install python-pip python-setuptools

2. Next, install Classifier (for the current user only) using the commands below (the first command installs wheel because it looks like the installation fails if it's not installed first):
pip install --user wheel
pip install --user classifier

3. The Classifier executable is installed under ~/.local/bin, and this may not be in your PATH by default. To add ~/.local/bin/ to your PATH, paste PATH="$HOME/.local/bin:$PATH" in your ~/.bashrc file (replace it with ~/.zshrc if you use Zsh) file. You can use the command below to do this from a terminal:
echo "PATH=\"\$HOME/.local/bin:\$PATH\"" >> ~/.bashrc

And finally, source the ~/.bashrc (or ~/.zshrc if you use Zsh) so the new configuration is used in the current terminal (opening a new shell should work as well):
. ~/.bashrc
(there's a dot, then a space followed by ~/.bashrc)

Later on, if you want to update Classifier, use the following command:
pip install --user --upgrade classifier

To download the Classifier code, report bugs, etc., see its GitHub page.