A powerful CLI tool for batch file renaming and organizing with an intuitive interface, preview mode, and undo capability.
✨ Multiple Renaming Strategies:
- Numeric sequence (file001, file002, ...)
- Alphabetical order
- Creation date
- Last modification date
- File size
- File type/extension
- Custom prefix/suffix
📁 Smart Grouping:
- Group by creation date
- Group by modification date
- Group by size range
- Group by file type
🔍 Preview Mode:
- See changes before they happen
- Beautiful table display with Rich library
- Confirm before executing
↩️ Undo Capability:
- Revert the last operation
- Automatic history tracking
- Per-directory undo support
🎯 Flexible Filtering:
- Filter by file extensions
- Interactive extension selection
- Support for multiple extensions
Install florg directly from PyPI using pip:
pip install florgThat's it! The organize command will be available immediately.
For development or the latest changes:
- Clone the repository:
git clone https://github.com/laisario/florg.git
cd florg- Install in development mode:
pip install -e .florg automatically installs these dependencies:
click- CLI frameworkrich- Beautiful terminal outputquestionary- Interactive prompts
organize /path/to/directoryThis will:
- Show available files
- Prompt you to choose an organization method
- Display a preview of changes
- Ask for confirmation
- Execute the operation
organize [OPTIONS] DIRECTORYOptions:
--group- Enable grouping mode (organize files into folders)--undo- Revert the last operation in this directory--no-preview- Skip preview and execute immediately--extensions,-e- Filter by file extensions (comma-separated)
organize ~/Documents/photosThe tool will interactively guide you through:
- Choosing a renaming strategy
- Setting parameters (prefix, suffix, etc.)
- Showing a preview of all changes
- Asking for confirmation
organize ~/Downloads --extensions .pdf,.docxOnly process PDF and Word documents.
organize ~/Music --no-previewExecute immediately without confirmation (use with caution!).
organize ~/Documents --groupAfter choosing a rename strategy, you'll be asked how to group files:
- By date (folders like "2025-11-04")
- By size range (folders like "Small (10 KB - 1 MB)")
- By file type (folders like "pdf", "jpg")
organize ~/Downloads --group --extensions .jpg,.png,.gifFilter for image files and organize them into folders.
organize ~/Documents --undoRevert the last batch operation performed in this directory.
Rename files with sequential numbers.
Prompts:
- Starting number (default: 1)
- Padding digits (default: 3)
- Prefix (optional)
- Suffix (optional)
Example output:
file001.txt
file002.txt
file003.txt
Sort and optionally rename files alphabetically.
Prompts:
- Reverse order? (Y/n)
- Prefix (optional)
- Suffix (optional)
Example output:
document_a.txt
document_b.txt
document_c.txt
Rename based on file creation date.
Prompts:
- Date format (default: %Y%m%d)
- Prefix (optional)
- Suffix (optional)
Example output:
20251104_1.jpg
20251104_2.jpg
20251105_1.jpg
Rename based on last modification date.
Prompts:
- Date format (default: %Y%m%d)
- Prefix (optional)
- Suffix (optional)
Example output:
mod_20251104.pdf
mod_20251103.pdf
Rename files sorted by size.
Prompts:
- Sort order (ascending/descending)
- Prefix (optional)
- Suffix (optional)
Example output:
001_15.2KB.jpg
002_124.5KB.jpg
003_1.2MB.jpg
Organize by file type with sequential numbering.
Prompts:
- Keep original names? (Y/n)
- Prefix (optional)
- Suffix (optional)
Example output:
jpg_001.jpg
jpg_002.jpg
pdf_001.pdf
Simply add prefix and/or suffix to existing names.
Prompts:
- Prefix text
- Suffix text
Example output:
PREFIX_original_name_SUFFIX.txt
Groups files into folders based on creation date.
Folder names: 2025-11-04/, 2025-11-03/
Groups files into folders based on modification date.
Folder names: 2025-11-04/, 2025-11-03/
Groups files into predefined size categories.
Folder names:
Tiny (< 10 KB)/Small (10 KB - 1 MB)/Medium (1 MB - 10 MB)/Large (10 MB - 100 MB)/Huge (> 100 MB)/
Groups files by extension.
Folder names: txt/, jpg/, pdf/
By default, the tool shows a beautiful preview of all changes before executing:
┌─────────────── Rename Preview ───────────────┐
│ # Current Name → New Name │
├─────────────────────────────────────────────┤
│ 1 image.jpg → photo_001.jpg │
│ 2 document.txt → photo_002.txt │
│ 3 file.pdf → photo_003.pdf │
└─────────────────────────────────────────────┘
Total files to rename: 3
Do you want to proceed with these changes? (Y/n):
Every operation is automatically saved to history. You can undo the last operation:
organize ~/Documents --undoThis will:
- Load the last operation for that directory
- Show what will be reverted
- Ask for confirmation
- Move all files back to original locations
- Remove empty folders (for group operations)
History Location: ~/.florg_history.json
The tool handles various error scenarios:
- ✓ Permission errors - Shows clear error messages
- ✓ Name collisions - Automatically appends (1), (2), etc.
- ✓ Invalid characters - Sanitizes filenames
- ✓ Missing files - Gracefully skips
- ✓ Interrupted operations - Partial operations are tracked
Run the test suite:
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=organize --cov-report=htmlflorg/
├── organize/
│ ├── __init__.py
│ ├── cli.py # Main CLI entry point
│ ├── renamer.py # Renaming strategies
│ ├── grouper.py # Grouping logic
│ ├── history.py # Undo functionality
│ ├── preview.py # Preview display
│ ├── filters.py # File filtering
│ └── utils.py # Utility functions
├── tests/
│ ├── test_renamer.py
│ ├── test_grouper.py
│ ├── test_history.py
│ └── test_filters.py
├── setup.py
├── requirements.txt
└── README.md
# Clone the repository
git clone https://github.com/laisario/florg.git
cd florg
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytestThe project uses black for code formatting:
black organize/ tests/Potential features for future versions:
- 🔄 Recursive mode for subdirectories
- 📝 Configuration file support
- 🔍 Regex pattern support
- 📊 Duplicate file detection
- 🏷️ EXIF/metadata-based renaming
- 🌐 Web interface
- 🔌 Plugin system for custom strategies
- 📅 Scheduled/automated organization
- 🌍 Multi-language support
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Make sure your Python scripts directory is in your PATH:
# On Linux/Mac
export PATH="$HOME/.local/bin:$PATH"
# On Windows (PowerShell)
$env:Path += ";$HOME\AppData\Local\Programs\Python\Python3X\Scripts"Ensure you have write permissions in the target directory:
chmod u+w /path/to/directoryCheck if the history file exists:
cat ~/.florg_history.jsonIf corrupted, you can reset it:
rm ~/.florg_history.jsonIf you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include error messages and steps to reproduce
- Built with Click for CLI handling
- Styled with Rich for beautiful output
- Interactive prompts powered by Questionary
Made with ❤️