Skip to content

An automated file organization tool that monitors your Downloads, Pictures, and Desktop folders and automatically sorts files into categorized directories based on their file extensions.

License

Notifications You must be signed in to change notification settings

Benji918/desktop_cleaner-master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Desktop Cleaner πŸ—‚οΈ

An automated file organization tool that monitors your Downloads, Pictures, and Desktop folders and automatically sorts files into categorized directories based on their file extensions.

πŸ“‹ Table of Contents

🌟 Overview

Desktop Cleaner is a Python-based file management utility that automatically organizes your files by monitoring specified directories and moving files to categorized folders based on their extensions. It runs continuously in the background and organizes files as soon as they appear in the watched directories.

✨ Features

  • Real-time Monitoring: Uses watchdog to monitor file system events
  • Automatic Organization: Sorts files by type into predefined categories
  • Date-based Structure: Creates year/month subdirectories for better organization
  • Duplicate Handling: Automatically renames files to prevent overwrites
  • Multi-directory Support: Monitors Downloads, Pictures, and Desktop simultaneously
  • Extensive File Type Support: Handles 80+ file extensions across multiple categories
  • Background Operation: Runs silently in the background with minimal resource usage

πŸ”§ How It Works

  1. File Detection: The tool monitors your Downloads, Pictures, and Desktop folders for new files
  2. Extension Recognition: When a file is detected, it identifies the file type by its extension
  3. Category Assignment: Files are categorized into groups like media, documents, programming files, etc.
  4. Date Organization: Files are placed in year/month subdirectories (e.g., 2024/JAN/)
  5. Conflict Resolution: If a file with the same name exists, it adds a number suffix to make it unique
  6. File Movement: The file is moved to its designated organized location

πŸ“¦ Installation

Prerequisites

  • Python 3.6 or higher
  • pip (Python package installer)

Install Dependencies

pip install watchdog

Clone the Repository

git clone https://github.com/yourusername/desktop-cleaner.git
cd desktop-cleaner

πŸš€ Usage

Basic Usage

  1. Navigate to the project directory:

    cd desktop_cleaner
  2. Run the cleaner:

    python cleandesk.py
  3. The tool will start monitoring your directories. You'll see it running until you stop it with Ctrl+C.

Running as a Background Service

On Linux/macOS:

nohup python cleandesk.py &

On Windows: You can create a batch file or use Task Scheduler to run it automatically on startup.

πŸ“ File Organization Structure

Files are organized in the following structure:

~/Downloads/holder of things/
β”œβ”€β”€ 2024/
β”‚   β”œβ”€β”€ JAN/
β”‚   β”‚   β”œβ”€β”€ media/
β”‚   β”‚   β”‚   β”œβ”€β”€ images/
β”‚   β”‚   β”‚   β”œβ”€β”€ audio/
β”‚   β”‚   β”‚   └── video/
β”‚   β”‚   β”œβ”€β”€ text/
β”‚   β”‚   β”‚   β”œβ”€β”€ pdf/
β”‚   β”‚   β”‚   β”œβ”€β”€ microsoft/
β”‚   β”‚   β”‚   └── presentations/
β”‚   β”‚   β”œβ”€β”€ programming/
β”‚   β”‚   β”‚   β”œβ”€β”€ python/
β”‚   β”‚   β”‚   β”œβ”€β”€ java/
β”‚   β”‚   β”‚   └── database/
β”‚   β”‚   └── other/
β”‚   β”‚       β”œβ”€β”€ compressed/
β”‚   β”‚       β”œβ”€β”€ executables/
β”‚   β”‚       └── internet/
β”‚   └── FEB/
β”‚       └── [same structure]
└── 2025/
    └── [same structure]

πŸ“„ Supported File Types

Media Files

  • Images: .jpg, .jpeg, .png, .gif, .bmp, .svg, .tiff, .psd, .ai, .cr2
  • Audio: .mp3, .wav, .ogg, .wma, .m3u, .midi, .aif
  • Video: .mp4, .avi, .mkv, .mov, .wmv, .flv, .3gp

Documents

  • Text: .txt, .rtf, .tex, .odt
  • PDF: .pdf
  • Microsoft Office: .doc, .docx, .xls, .xlsx, .ppt, .pptx
  • Presentations: .key, .odp, .pps

Programming Files

  • Python: .py
  • Java: .java, .class
  • C/C++: .c, .h
  • Web: .html, .css, .js, .php, .asp
  • Database: .csv, .sql, .json, .xml, .db
  • Shell: .sh

Other Categories

  • Compressed: .zip, .rar, .7z, .tar.gz
  • Executables: .exe, .apk, .jar, .bat
  • Fonts: .ttf, .otf, .fnt
  • System: .dll, .sys, .ini, .ico

βš™οΈ Configuration

Customizing Watch Directories

Edit the cleandesk.py file to modify watched directories:

# Current default paths
watch_path_1 = Path.home() / 'Downloads'
watch_path_2 = Path.home() / 'Pictures'
watch_path_3 = Path.home() / 'Desktop'

# Destination directories
destination_root_1 = Path.home() / 'Downloads/holder of things'
destination_root_2 = Path.home() / 'Pictures/holder of things'
destination_root_3 = Path.home() / 'Desktop/holder of things'

Adding New File Types

Edit extensions.py to add new file extensions:

extension_paths = {
    '.your_extension': 'category/subcategory',
    # Add your custom extensions here
}

Changing Destination Folder Names

Modify the destination paths in cleandesk.py to use different folder names:

destination_root_1 = Path.home() / 'Downloads/Organized Files'

πŸ› οΈ Troubleshooting

Common Issues

  1. Permission Errors

    • Ensure Python has permission to read/write in the target directories
    • On macOS, you might need to grant Terminal full disk access
  2. Files Not Moving

    • Check if the file extension is listed in extensions.py
    • Verify the destination directory exists and is writable
  3. Script Stops Unexpectedly

    • Check for file system errors or insufficient disk space
    • Review the console output for error messages

Debug Mode

Add print statements to EventHandler.py for debugging:

def on_modified(self, event):
    print(f"Event detected: {event}")
    # ... rest of the code

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Add new file types to extensions.py
  4. Improve the organization logic in EventHandler.py
  5. Add error handling and logging
  6. Write tests for new functionality
  7. Commit your changes: git commit -m 'Add amazing feature'
  8. Push to the branch: git push origin feature/amazing-feature
  9. Open a Pull Request

Ideas for Contributions

  • Add a GUI interface
  • Implement configuration file support
  • Add logging functionality
  • Create platform-specific installers
  • Add support for cloud storage synchronization
  • Implement undo functionality
  • Add file preview before moving

πŸ“ˆ Future Enhancements

  • GUI interface with system tray integration
  • Configuration file support (YAML/JSON)
  • Logging and activity history
  • Undo functionality
  • Cloud storage integration
  • Machine learning-based file categorization
  • Email notifications for organized files
  • Scheduled cleanup routines

⚠️ Important Notes

  • Backup your files before running the tool for the first time
  • The tool moves files (not copies), so they will be relocated from their original position
  • Large files might take a moment to process
  • The tool runs continuously until manually stopped

πŸ“‹ System Requirements

  • Operating System: Windows, macOS, or Linux
  • Python: 3.6 or higher
  • RAM: Minimal (< 50MB)
  • Storage: Depends on files being organized
  • Permissions: Read/write access to monitored directories

About

An automated file organization tool that monitors your Downloads, Pictures, and Desktop folders and automatically sorts files into categorized directories based on their file extensions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages