A CLI tool for batch file renaming and organizing
Project description
florg - File Organizer by Command line
A powerful CLI tool for batch file renaming and organizing with an intuitive interface, preview mode, and undo capability.
Features
โจ 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
Installation
From PyPI (Recommended)
Install florg directly from PyPI using pip:
pip install florg
That's it! The organize command will be available immediately.
From Source
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 .
Dependencies
florg automatically installs these dependencies:
click- CLI frameworkrich- Beautiful terminal outputquestionary- Interactive prompts
Usage
Basic Usage
organize /path/to/directory
This will:
- Show available files
- Prompt you to choose an organization method
- Display a preview of changes
- Ask for confirmation
- Execute the operation
Command Line Options
organize [OPTIONS] DIRECTORY
Options:
--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)
Examples
Basic Rename with Preview (Default)
organize ~/Documents/photos
The tool will interactively guide you through:
- Choosing a renaming strategy
- Setting parameters (prefix, suffix, etc.)
- Showing a preview of all changes
- Asking for confirmation
Rename Specific Extensions
organize ~/Downloads --extensions .pdf,.docx
Only process PDF and Word documents.
Skip Preview for Automation
organize ~/Music --no-preview
Execute immediately without confirmation (use with caution!).
Group Files into Folders
organize ~/Documents --group
After 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")
Combined: Filter and Group
organize ~/Downloads --group --extensions .jpg,.png,.gif
Filter for image files and organize them into folders.
Undo Last Operation
organize ~/Documents --undo
Revert the last batch operation performed in this directory.
Renaming Strategies
1. Numeric Increase
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
2. Alphabetical Order
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
3. Creation Date
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
4. Modification Date
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
5. File Size
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
6. File Type/Extension
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
7. Custom Prefix/Suffix
Simply add prefix and/or suffix to existing names.
Prompts:
- Prefix text
- Suffix text
Example output:
PREFIX_original_name_SUFFIX.txt
Grouping Strategies
Same Creation Date
Groups files into folders based on creation date.
Folder names: 2025-11-04/, 2025-11-03/
Same Modification Date
Groups files into folders based on modification date.
Folder names: 2025-11-04/, 2025-11-03/
Same Size Range
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)/
Same File Type
Groups files by extension.
Folder names: txt/, jpg/, pdf/
Preview Mode
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):
Undo Feature
Every operation is automatically saved to history. You can undo the last operation:
organize ~/Documents --undo
This 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
Error Handling
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
Testing
Run the test suite:
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=organize --cov-report=html
Project Structure
florg/
โโโ 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
Development
Setting Up Development Environment
# 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
pytest
Code Style
The project uses black for code formatting:
black organize/ tests/
Future Enhancements
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
Contributing
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
License
This project is licensed under the MIT License - see the LICENSE file for details.
Troubleshooting
Command not found after installation
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"
Permission denied errors
Ensure you have write permissions in the target directory:
chmod u+w /path/to/directory
Undo not working
Check if the history file exists:
cat ~/.florg_history.json
If corrupted, you can reset it:
rm ~/.florg_history.json
Support
If 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
Acknowledgments
- Built with Click for CLI handling
- Styled with Rich for beautiful output
- Interactive prompts powered by Questionary
Made with โค๏ธ
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 florg-1.0.0.tar.gz.
File metadata
- Download URL: florg-1.0.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a942a564f668dc0cdd18fa730a0b369c3c4b6f9b144f96a50b0631bbca5871e0
|
|
| MD5 |
f6321844a38c2e5e7096e11914bfc362
|
|
| BLAKE2b-256 |
9ced7b3d5c7c7f200d7b7349664d55bbb3ee7d2bd9bbd301720372c54720f04d
|
Provenance
The following attestation bundles were made for florg-1.0.0.tar.gz:
Publisher:
pipy-publish.yml on laisario/florg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
florg-1.0.0.tar.gz -
Subject digest:
a942a564f668dc0cdd18fa730a0b369c3c4b6f9b144f96a50b0631bbca5871e0 - Sigstore transparency entry: 699837088
- Sigstore integration time:
-
Permalink:
laisario/florg@7ef65de199a596737befffade57c33ed88fdcf30 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/laisario
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipy-publish.yml@7ef65de199a596737befffade57c33ed88fdcf30 -
Trigger Event:
release
-
Statement type:
File details
Details for the file florg-1.0.0-py3-none-any.whl.
File metadata
- Download URL: florg-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.1 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 |
7bcda3600aa8cc5d62f6c1b820371a36f27b314dffc5ddade0a6244de334dae0
|
|
| MD5 |
0abf818c64d1f383da8a16aeba08409c
|
|
| BLAKE2b-256 |
1d103956adeb2a2c4220b1c13180d47a95448bf25fd285d78542a0a6b11052c8
|
Provenance
The following attestation bundles were made for florg-1.0.0-py3-none-any.whl:
Publisher:
pipy-publish.yml on laisario/florg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
florg-1.0.0-py3-none-any.whl -
Subject digest:
7bcda3600aa8cc5d62f6c1b820371a36f27b314dffc5ddade0a6244de334dae0 - Sigstore transparency entry: 699837090
- Sigstore integration time:
-
Permalink:
laisario/florg@7ef65de199a596737befffade57c33ed88fdcf30 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/laisario
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipy-publish.yml@7ef65de199a596737befffade57c33ed88fdcf30 -
Trigger Event:
release
-
Statement type: