LLM-powered directory organizer using Google Gemini
Project description
sortai
LLM-powered directory organizer. Uses Google Gemini to suggest a folder structure from filenames and (for text-based files) the first ~500 characters of content, then moves files into the suggested subfolders.
- Dry-run by default – see exactly what would move where before touching anything.
- Confirm before apply – with
--apply, you are prompted to confirm before any files are moved.
📦 PyPI Package: https://pypi.org/project/sortai/0.1.0/
Install
Install from PyPI:
pip install sortai
Or view the package on PyPI.
Development install from source:
git clone https://github.com/ajs2583/sortai.git
cd sortai
pip install -e .
Setup
Set your Google Gemini API key (required):
export GEMINI_API_KEY=your_key_here
Get a key at: https://aistudio.google.com/app/apikey
You can copy .env.example to .env and set GEMINI_API_KEY there; load it with your shell or a tool like python-dotenv if you use one (sortai does not load .env automatically).
Demo
Demo showing sortai test-demo dry-run preview, then --apply with confirmation.
Note: Create
docs/demo.gifusing ScreenToGif or similar tool. The GIF will automatically display on both GitHub and PyPI once uploaded.
Usage
| Command | Description |
|---|---|
sortai <path> |
Dry-run: show what would be moved where (default). |
sortai <path> --apply |
After dry-run, prompt and then actually move files. |
sortai <path> --depth 2 |
Organize up to 2 levels of subfolders (e.g. documents/work). |
sortai <path> --model gemini-2.5-flash |
Override Gemini model (default: gemini-2.5-flash). |
sortai --version |
Print version. |
sortai --help |
Show help. |
Example output
Before (flat directory):
my-folder/
├── report.pdf
├── notes.txt
├── budget.csv
├── vacation.jpg
└── readme.md
Dry-run:
$ sortai ./my-folder
Dry run – would move:
report.pdf -> documents/
notes.txt -> documents/
budget.csv -> finance/
vacation.jpg -> images/
readme.md -> (keep at root)
Run with --apply to perform moves.
After applying:
my-folder/
├── readme.md
├── documents/
│ ├── report.pdf
│ └── notes.txt
├── finance/
│ └── budget.csv
└── images/
└── vacation.jpg
Supported file types for content reading
sortai reads the first ~500 characters of content for:
.pdf(first page via pdfplumber).txt,.md,.csv(plain text).docx(paragraph text via python-docx)
All other files are categorized by filename and extension only.
Releasing
GitHub Releases (Automated)
-
Bump version in
pyproject.tomlandsortai/__init__.py(e.g.,0.1.0→0.1.1). -
Commit and push:
git add pyproject.toml sortai/__init__.py git commit -m "Bump version to 0.1.1" git push
-
Create and push a tag:
git tag v0.1.1 git push origin v0.1.1
-
GitHub Actions will automatically:
- Verify version consistency
- Build the package (wheel + sdist)
- Create a GitHub release with release notes
- Attach the built artifacts
The workflow triggers on tags matching v*.*.* (e.g., v0.1.0). You can also trigger it manually from the Actions tab.
Publishing to PyPI
-
Create a PyPI account (and optionally Test PyPI for testing):
-
Install build tools (one-time):
pip install build twine
-
Bump version in
pyproject.tomlandsortai/__init__.pywhen releasing a new version. -
Build the package (from the project root):
python -m build
This creates
dist/sortai-0.1.0.tar.gzand a wheel. -
Upload to PyPI (manual):
twine upload dist/*
Twine will prompt for your PyPI username and password. Prefer an API token (username:
__token__, password: your token) over your account password.Or enable automated PyPI upload: Add your PyPI API token as a GitHub secret named
PYPI_API_TOKEN, then edit.github/workflows/release.ymland changeif: falsetoif: truein the "Upload to PyPI" step. Releases will then automatically publish to PyPI.To try Test PyPI first:
twine upload --repository testpypi dist/*
Then install with:
pip install -i https://test.pypi.org/simple/ sortai
Note: If the name sortai is already taken on PyPI, change the name in pyproject.toml to something unique (e.g. sortai-cli) and publish under that name.
License
MIT
Project details
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 sortai-0.1.2.tar.gz.
File metadata
- Download URL: sortai-0.1.2.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb839164a461370dd4422ad645a8e2e2c877494cddc77f899561e88f3ef3da76
|
|
| MD5 |
432b429dd81ef0a78570ba1b73de7689
|
|
| BLAKE2b-256 |
4b8316c8e69444a079db55260969c522b4f22464c1fbd61f5bde985383388adb
|
File details
Details for the file sortai-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sortai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d44cc42fb433908aadb6bcebec96a294e020fb3a216907c30914c5debbfe75f2
|
|
| MD5 |
ad58297137d0ce3fbee1988c84d595da
|
|
| BLAKE2b-256 |
e821beb3f3fcd25bf3c5dfda69be0cbbfead3027d083b4cc41c552e783e6cfee
|