mnestorov / file-classifier

The File Classifier is a Python script that monitors a specified directory (typically the Downloads folder) and automatically organizes files into different folders based on their file types.
MIT License
4 stars 2 forks source link
classification classifier file-classifier file-manager fileclassify filemanager python python-script

File_Classifier

File Classifier

Licence

Support The Project

Your support is greatly appreciated and will help ensure the project's continued development and improvement. Thank you for being a part of the community!



Overview

The File Classifier is a Python script that monitors a specified directory (typically the Downloads folder) and automatically organizes files into different folders based on their file types and the date they were created or last modified. It can also identify and delete duplicate files.

Prerequisites

To run the File Classifier, you need:

You can install the watchdog package using the following command:

pip install watchdog

Installation

Download the main script file main.py and the configuration file config.py.

Open the config.py file and modify the download_folder variable to the path of the directory you want to monitor (e.g., your Downloads folder).

In the same file, you can also modify the classification_rules dictionary to customize the folders and file types used for classification. The key is the folder name, and the value is a list of file extensions.

Optionally, you can customize the GREEN and RESET variables in config.py to change the color of the printed messages.

Usage

Open a terminal or command prompt, navigate to the folder containing the main.py and config.py files.

Run the script using the following command:

python main.py

The script will start monitoring the specified directory. When a new file is added or an existing file is modified, the script will automatically move the file to the appropriate folder based on its file type and date.

If a duplicate file is detected, the script will delete it, provided that it has the same name as the original file plus a number in parentheses (e.g., "invoice (1).pdf").

To stop the script, press Ctrl+C.

Bash Command

To use bash command to run the script, first make sure that the Python script file main.py is executable.

You can do this by running the following command in your terminal:

chmod +x main.py

Also, make the bash script executable by running:

chmod +x start.sh

Customization

Run the script at startup

To run the script at startup on Ubuntu, you have a few options.

One common approach is to add an entry to the "Startup Applications" tool:

Now, the bash script will run automatically when you log in to your Ubuntu system.

Note: Please note that this approach will only work when you log in with a graphical environment, as it relies on the GNOME startup applications feature. If you need to run the script in a non-GUI environment or before user login, you may need to use a different method, such as a systemd service or a cron job.

TODOs

Support The Project

If you find this script helpful and would like to support its development and maintenance, please consider the following options:



Your support is greatly appreciated and will help ensure the project's continued development and improvement. Thank you for being a part of the community!


License

This project is licensed under the MIT License.