File Organizer

File Organizer Screenshot

Project Overview

The File Organizer is a powerful Python application designed to automatically sort and organize files based on their types and modification dates. Built with a user-friendly Tkinter interface, this tool helps maintain a clean and structured file system by categorizing files into appropriate folders, handling duplicates intelligently, and providing visual feedback through progress tracking.

Interactive Demo

Try out a simulation of the File Organizer below. Click "Organize Files" to see how different file types would be sorted into folders.

Unorganized Files

Features

Date-Based Organization

Organizes files into year, month, and week folders based on their modification dates for a chronological structure.

Type-Based Classification

Categorizes files into folders by type (images, documents, audio, video, archives, etc.) for easy access.

Duplicate Handling

Intelligently identifies and handles duplicate files to prevent overwrites and data loss.

Graphical Interface

User-friendly Tkinter GUI makes the tool accessible to users of all technical backgrounds.

Progress Tracking

Visual progress indicators keep you informed about the organization process and completion status.

Empty Folder Cleanup

Optional removal of empty folders after organization to maintain a clean directory structure.

How It Works

The File Organizer processes files through several key steps:

  1. Scanning: First, it scans the specified directory to identify all files for organization.
  2. Classification: Each file is classified based on its extension type (image, document, audio, etc.).
  3. Date Analysis: The modification date of each file is examined to determine its chronological placement.
  4. Folder Creation: Required folder structures are automatically created based on file types and dates.
  5. File Movement: Files are moved to their appropriate destination folders while checking for duplicates.
  6. Cleanup: Optionally, empty folders are removed from the directory structure.

Technical Implementation

The File Organizer is built with Python and leverages several key libraries:

Core Components

Key Functions

The organize_files function handles the core organization logic:

def organize_files(directory, delete_empty_folders=False, progress_callback=None): # Define the folder names for each file type folders = { 'images': ['.jpg', '.jpeg', '.png', '.gif', '.bmp'], 'documents': { 'word': ['.doc', '.docx'], 'excel': ['.xls', '.xlsx'], 'pdf': ['.pdf'], 'text': ['.txt'], 'ppt': ['.ppt', '.pptx'] }, 'audio': ['.mp3', '.wav', '.aac'], 'video': ['.mp4', '.mov', '.avi'], 'archives': ['.zip', '.rar', '.tar', '.gz'], 'scripts': ['.py', '.js', '.sh'], 'installers': ['.exe', '.msi', '.dmg'], 'setups': ['setup.exe', 'setup.msi'] } # Create folders if they do not exist for folder in folders: folder_path = os.path.join(directory, folder) if not os.path.exists(folder_path): os.makedirs(folder_path)

The duplicate detection function uses regular expressions to identify common duplicate patterns:

def is_duplicate(file1, file2): # Remove common duplicate suffixes like (1), (2), etc. base1 = re.sub(r'\(\d+\)', '', file1) base2 = re.sub(r'\(\d+\)', '', file2) return base1.strip() == base2.strip()

How to Use

  1. Launch the application by running the Python script
  2. Click "Select Directory" to choose the folder you want to organize
  3. Choose whether to delete empty folders after organization
  4. Wait for the organization process to complete
  5. Explore your newly organized file system

Applications

The File Organizer is ideal for various scenarios:

Back to Projects