Skip to content

πŸ—‚οΈ A powerful CLI tool for automatically organizing files by type, date, or custom rules. Features dry-run mode, undo functionality, and beautiful console output.

License

Notifications You must be signed in to change notification settings

locfaker/file-organizer-cli

Repository files navigation

πŸ—‚οΈ File Organizer CLI Tool

Python Version License: MIT Tests Coverage GitHub release GitHub stars GitHub issues GitHub forks

A powerful command-line tool for automatically organizing files by type, date, or custom rules

Features β€’ Installation β€’ Usage β€’ Documentation β€’ Contributing

A powerful command-line tool for automatically organizing files by type, date, or custom rules. Perfect for cleaning up messy Downloads folders, organizing project files, or maintaining a tidy file system.

✨ Features

  • πŸ—‚οΈ Multiple Organization Types: Organize by file type, creation/modification date, or custom rules
  • πŸ‘€ Dry Run Mode: Preview changes before executing them
  • βͺ Undo Functionality: Easily reverse organization operations
  • 🎯 Custom Rules: Define your own organization patterns with flexible rule engine
  • πŸš€ Fast & Efficient: Handles large directories with minimal resource usage
  • πŸ”§ Configurable: Extensive configuration options via YAML files
  • πŸ“Š Rich Output: Beautiful, informative command-line interface
  • πŸ”’ Safe: Built-in safeguards and error handling

πŸš€ Quick Start

Installation

# Method 1: Quick install from source
git clone https://github.com/locfaker/file-organizer-cli.git
cd file-organizer-cli
python scripts/install.py

# Method 2: Manual install
pip install -r requirements.txt
pip install -e .

# Method 3: Using Make (if available)
make install-dev

Basic Usage

# Organize files by type (images, documents, videos, etc.)
file-organizer organize /path/to/messy/folder

# Preview changes without executing
file-organizer organize /path/to/folder --dry-run

# Organize by date
file-organizer organize /path/to/folder --type date

# Undo last operation
file-organizer undo

πŸ“– Usage Examples

Organize Downloads Folder

# Preview organization
file-organizer preview ~/Downloads

# Organize by file type
file-organizer organize ~/Downloads --type type

# Check what was organized
file-organizer undo --list

Date-based Organization

# Organize photos by year/month
file-organizer organize ~/Pictures --type date

# Use custom date format (configured in config file)
file-organizer organize ~/Documents --type date

Custom Configuration

# Create default configuration file
file-organizer init-config

# Use custom config
file-organizer --config my-config.yaml organize ~/folder

πŸ› οΈ Configuration

Create a configuration file to customize organization behavior:

file-organizer init-config --output ~/.config/file-organizer/config.yaml

Example Configuration

# File type mappings
file_types:
  images:
    - .jpg
    - .jpeg
    - .png
    - .gif
    - .webp
  documents:
    - .pdf
    - .doc
    - .docx
    - .txt
  code:
    - .py
    - .js
    - .html
    - .css

# Custom organization rules
custom_rules:
  - name: "Backup Files"
    pattern: "*.bak"
    pattern_type: "glob"
    destination: "backups"
  
  - name: "Large Files"
    pattern_type: "size"
    min_size: 104857600  # 100MB
    destination: "large_files"

# Date organization settings
date_format: "%Y/%m"  # Year/Month
use_creation_date: true

# General settings
create_subdirs: true
max_depth: 10

πŸ“‹ Command Reference

Main Commands

Command Description
organize Organize files in a directory
preview Preview organization without making changes
undo Undo previous organization operations
init-config Create a default configuration file

Organization Types

Type Description
type Organize by file extension/type (default)
date Organize by file creation/modification date
custom Use custom rules defined in configuration

Global Options

Option Description
--config Path to configuration file
--help Show help message
--version Show version information

Organize Options

Option Description
--type Organization type (type/date/custom)
--dry-run Preview changes without executing
--verbose Show detailed output

Undo Options

Option Description
--session-id Undo specific session
--dry-run Preview undo without executing
--list List available undo sessions

πŸ”§ Advanced Usage

Custom Rules

Define powerful custom rules in your configuration:

custom_rules:
  # Organize by file size
  - name: "Large Media Files"
    pattern_type: "size"
    min_size: 52428800  # 50MB
    destination: "large_media/{year}"
  
  # Organize by filename pattern
  - name: "Screenshots"
    pattern: "screenshot*"
    pattern_type: "name"
    destination: "screenshots/{year}/{month}"
  
  # Organize by regex
  - name: "Version Files"
    pattern: ".*v\\d+\\.\\d+.*"
    pattern_type: "regex"
    destination: "versions"

Template Variables

Use template variables in destination paths:

  • {filename} - File name without extension
  • {extension} - File extension
  • {full_name} - Complete file name
  • {year}, {month}, {day} - Current date
  • {file_year}, {file_month}, {file_day} - File date

Batch Operations

# Organize multiple directories
for dir in ~/Downloads ~/Desktop ~/Documents; do
    file-organizer organize "$dir" --type type
done

# Organize with different rules
file-organizer organize ~/Pictures --type date
file-organizer organize ~/Downloads --type type
file-organizer organize ~/Projects --type custom

πŸ§ͺ Testing

Run the test suite:

# Run all tests
pytest

# Run with coverage
pytest --cov=src/file_organizer

# Run specific test file
pytest tests/test_core.py -v

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

# Clone the repository
git clone https://github.com/locfaker/file-organizer-cli.git
cd file-organizer-cli

# Install development dependencies
pip install -r requirements.txt

# Install pre-commit hooks
pre-commit install

# Run tests
pytest

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Click for the CLI interface
  • Rich for beautiful terminal output
  • PyYAML for configuration file handling

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Include your configuration file and command used (remove sensitive information)

Made with ❀️ for developers who love organized file systems


πŸ“ˆ Project Status

  • βœ… Production Ready: Fully tested and documented
  • βœ… Cross Platform: Windows, macOS, Linux support
  • βœ… Active Development: Regular updates and improvements
  • βœ… Community Driven: Open to contributions and feedback

Star ⭐ this repository if you find it useful!

About

πŸ—‚οΈ A powerful CLI tool for automatically organizing files by type, date, or custom rules. Features dry-run mode, undo functionality, and beautiful console output.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published