AI-powered file organization tool that intelligently organizes files based on content analysis
Project description
Deep Organizer ๐ค๐
An intelligent AI agent that automatically organizes files in your directories using advanced language models and content analysis.
Overview
Deep Organizer is a Python-based AI agent that uses LangGraph and OpenAI's GPT models to intelligently analyze and organize files in a directory. The agent reads file contents, understands their purpose, creates appropriately named folders, and moves files into logical groupings automatically.
Features
- ๐ง AI-Powered Analysis: Uses GPT models to understand file content and context
- ๐ Smart Folder Creation: Automatically creates descriptive folders with proper naming
- ๐ Safety First: Protects important system files and folders from being moved
- ๐ Content-Based Organization: Analyzes file contents, not just extensions
- โก Automated Workflow: Single command execution with comprehensive reporting
- ๐ก๏ธ Error Handling: Robust error handling and validation
Installation
Prerequisites
- Python 3.8 or higher
- OpenAI API key (for GPT model access)
Option 1: Install from PyPI (Recommended)
pip install deep-organizer
Option 2: Install from Source
-
Clone the repository:
git clone <repository-url> cd deep-organizer
-
Install the package:
pip install -e .
Or for development with extra dependencies:
pip install -e ".[dev]"
Environment Setup
Create a .env file in your working directory or set environment variables:
OPENAI_API_KEY=your_openai_api_key_here
Or export the variable in your shell:
export OPENAI_API_KEY="your_openai_api_key_here"
Usage
Command Line Interface
After installation, you can use deep-organizer from anywhere in your terminal.
Basic Usage
# Organize files in the current directory
deep-organizer
# Organize files in a specific directory
deep-organizer --directory ~/Downloads
# Preview what would be organized (dry run)
deep-organizer --dry-run
Advanced Options
# Use verbose output to see detailed progress
deep-organizer --verbose
# Use a different AI model
deep-organizer --model "openai:gpt-4"
# Exclude additional files or folders
deep-organizer --exclude-files "secret.txt" "private.doc" \
--exclude-folders "temp" "cache"
# Adjust file reading limit
deep-organizer --max-file-size 2000
# Check environment setup
deep-organizer --check-env
Complete Example
# Organize Downloads folder with verbose output and dry-run first
deep-organizer --directory ~/Downloads --dry-run --verbose
# If satisfied with the preview, run for real
deep-organizer --directory ~/Downloads --verbose
What the Tool Does
The AI agent will:
- Scan all files in the specified directory
- Read and analyze file contents (up to specified character limit)
- Create appropriate folders based on content analysis
- Move files into their designated folders
- Provide a comprehensive summary of actions taken
Protected Files and Folders
The following items are automatically protected from being moved or analyzed:
Protected Files:
.env- Environment variablesmain.py- The organizer script itself.gitignore- Git ignore filerequirements.txt- Python dependencies
Protected Folders:
venv/- Virtual environment__pycache__/- Python cache.git/- Git repository data
How It Works
Core Components
-
File Discovery (
get_file_list())- Scans the current directory
- Filters out protected files and folders
- Returns a clean list for processing
-
Content Analysis (
read_file())- Safely reads text files with encoding handling
- Limits read size to prevent memory issues
- Handles binary files gracefully
-
Folder Management (
create_folder())- Creates folders with validation
- Prevents path traversal attacks
- Ensures proper naming conventions
-
File Movement (
move_file())- Safely moves files between directories
- Validates source and destination paths
- Prevents moving of protected files
-
AI Agent Integration
- Uses LangGraph's React agent framework
- Leverages OpenAI's GPT-4-mini for intelligent decisions
- Provides structured prompts for consistent behavior
Agent Behavior
The AI agent follows this workflow:
- Analysis Phase: Reads and analyzes file contents to understand their purpose
- Planning Phase: Determines logical folder structure based on content themes
- Creation Phase: Creates folders with descriptive, capitalized names
- Organization Phase: Moves files into appropriate folders
- Reporting Phase: Provides a summary of actions taken
Configuration
Model Configuration
By default, the agent uses openai:gpt-4-mini. You can modify this in main.py:
agent = create_react_agent(
model="openai:gpt-4", # or "anthropic:claude-3-sonnet" etc.
tools=[get_cur_dir, get_file_list, create_folder, move_file, read_file],
# ...
)
Safety Limits
Adjust these constants in main.py as needed:
MAX_FILE_READ_SIZE = 1000 # Characters to read per file
EXCLUDED_FILES = {".env", "main.py", ".gitignore", "requirements.txt"}
EXCLUDED_FOLDERS = {"venv", "__pycache__", ".git"}
Examples
Before Organization
/messy-directory/
โโโ report.pdf
โโโ vacation_photo.jpg
โโโ budget.xlsx
โโโ recipe.txt
โโโ presentation.pptx
โโโ song.mp3
โโโ code_snippet.py
After Organization
/messy-directory/
โโโ Documents/
โ โโโ report.pdf
โ โโโ budget.xlsx
โ โโโ presentation.pptx
โโโ Images/
โ โโโ vacation_photo.jpg
โโโ Audio/
โ โโโ song.mp3
โโโ Recipes/
โ โโโ recipe.txt
โโโ Code/
โโโ code_snippet.py
Troubleshooting
Common Issues
-
"Error running agent: API key not found"
- Ensure your
.envfile contains a validOPENAI_API_KEY - Verify the API key has sufficient credits
- Ensure your
-
"Permission denied" errors
- Ensure you have write permissions in the target directory
- Check if files are not currently in use by other applications
-
"Binary file cannot be read" messages
- This is normal behavior for binary files (images, executables, etc.)
- The agent will still organize them based on file extensions
Debug Mode
For debugging, you can add print statements or modify the recursion limit:
result = agent.invoke(
{"messages": [...]},
{"recursion_limit": 2000} # Increase for complex directories
)
Contributing
Contributions are welcome! Here are some ways you can help:
- ๐ Report bugs or issues
- ๐ก Suggest new features or improvements
- ๐ Improve documentation
- ๐ง Submit pull requests
Development Setup
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and test them
- Submit a pull request
Dependencies
- langgraph: Framework for building language model agents
- langchain[anthropic]: LangChain with Anthropic support
- python-dotenv: Environment variable management
Security Considerations
- The agent only operates on the current working directory
- Protected files and system folders are excluded by design
- File reading is limited to prevent memory exhaustion
- Path traversal attacks are prevented through validation
- API keys are kept secure in environment variables
Performance
- File Reading: Limited to 1000 characters per file for efficiency
- API Calls: Optimized to minimize token usage
- Memory Usage: Minimal memory footprint through streaming
- Processing Speed: Depends on file count and API response times
Roadmap
- Support for custom organization rules
- GUI interface for non-technical users
- Integration with cloud storage services
- Batch processing for multiple directories
- Custom AI model support
- Undo functionality
License
This project is licensed under the MIT License - see below for details:
MIT License
Copyright (c) 2024 Deep Organizer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Support
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Search existing issues on GitHub
- Create a new issue with detailed information
- Include your Python version, OS, and error messages
Made with โค๏ธ and AI | Organizing chaos, one directory at a time
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deep_organizer-1.0.0.tar.gz.
File metadata
- Download URL: deep_organizer-1.0.0.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f7018bfd6b7f71091242788cc4ca5a43b9dc46f23ab158615a0ddcba71f162b
|
|
| MD5 |
91bb177302c4b851d9afb4532707e89f
|
|
| BLAKE2b-256 |
33f2cfcbdd31417a1c6eb809424a0f44917898bc3126cc28fc58be2c463d2bb9
|
Provenance
The following attestation bundles were made for deep_organizer-1.0.0.tar.gz:
Publisher:
publish.yml on MarkCodering/deep-organizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_organizer-1.0.0.tar.gz -
Subject digest:
6f7018bfd6b7f71091242788cc4ca5a43b9dc46f23ab158615a0ddcba71f162b - Sigstore transparency entry: 583642179
- Sigstore integration time:
-
Permalink:
MarkCodering/deep-organizer@34276ba4c0b4130be2becf3c786f17e090c2fbc7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MarkCodering
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@34276ba4c0b4130be2becf3c786f17e090c2fbc7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file deep_organizer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: deep_organizer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
096d8c2f9775f8c6d7644199b21698bf6db10db422d57063e5d877871bdf4a8a
|
|
| MD5 |
d93a6476f9c07a2892b59f2f51848e20
|
|
| BLAKE2b-256 |
e3257c62f4dd30b032cc71ba99c76189775c966bc16dde641b4fc30cea0cdae5
|
Provenance
The following attestation bundles were made for deep_organizer-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on MarkCodering/deep-organizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_organizer-1.0.0-py3-none-any.whl -
Subject digest:
096d8c2f9775f8c6d7644199b21698bf6db10db422d57063e5d877871bdf4a8a - Sigstore transparency entry: 583642181
- Sigstore integration time:
-
Permalink:
MarkCodering/deep-organizer@34276ba4c0b4130be2becf3c786f17e090c2fbc7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MarkCodering
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@34276ba4c0b4130be2becf3c786f17e090c2fbc7 -
Trigger Event:
workflow_dispatch
-
Statement type: