A Rust CLI tool that automatically renames PDF files with meaningful, concise names using local LLMs via Ollama. Perfect for organizing documents with non-English filenames or long, complex names.
- ๐ Multi-language Support: Automatically translates non-English filenames
- ๐ค Local LLM Integration: Uses Ollama for privacy-preserving AI processing
- ๐ Automatic Setup: Installs Ollama and downloads models as needed
- ๐ฏ Smart Naming: Generates concise, meaningful 10-character names
- ๐ Batch Processing: Processes entire directories recursively
- ๐ Safe Operations: Dry-run mode by default, duplicate handling
- โก Fast & Efficient: Written in Rust for optimal performance
# Clone and build
git clone https://github.com/RustSandbox/pdf_renamer.git
cd pdf_renamer
cargo build --release
# Run the demo
./demo.sh
# Or use directly
./target/release/pdf-renamer /path/to/pdfs- Rust (1.70 or later)
- macOS or Linux (Windows support coming soon)
- Internet connection (for automatic Ollama setup and model downloads)
cargo install pdf-renamer-aiThis will install the pdf-renamer command globally.
git clone https://github.com/RustSandbox/pdf_renamer.git
cd pdf_renamer
cargo build --releaseThe binary will be available at target/release/pdf-renamer.
cargo install --path .# Dry run - see what would be renamed
pdf-renamer /path/to/pdf/folder
# Actually rename files
pdf-renamer --rename /path/to/pdf/folder# Use a specific model (default: command-r7b:latest)
pdf-renamer --model llama3.2:latest /path/to/pdfs
# Recommended models:
# - command-r7b:latest (default - best balance of speed and quality)
# - llama3.2:latest (excellent for complex names)
# - qwen2.5:latest (good multilingual support)
# - mistral-nemo:latest (fast and efficient)USAGE:
pdf-renamer [OPTIONS] <FOLDER_PATH>
ARGS:
<FOLDER_PATH> Path to the folder containing PDF files
OPTIONS:
-r, --rename Actually rename the files (dry run by default)
-m, --model <MODEL> Ollama model to use [default: command-r7b:latest]
-h, --help Print help information
-
Setup Phase:
- Checks if Ollama is installed (installs if needed)
- Ensures Ollama service is running
- Downloads the specified model if not available
-
Processing Phase:
- Scans the directory for PDF files
- Sends each filename to the LLM for translation/summarization
- Generates a meaningful 10-character alphanumeric name
- Renames files (if --rename flag is used)
-
Safety Features:
- Dry-run by default
- Handles duplicates by appending numbers
- Preserves original files on error
Before:
ู
ุตุฑ_ู
ู_ูุงุตุฑ_ุฅูู_ุญุฑุจ_ุฃูุชูุจุฑ.pdf
ุฃูุฑุงู_ููุฑู_ููุฑููู_ูุงูุญุฑูุฉ_ุงูุดููุนูุฉ_ุงูู
ุตุฑูุฉ.pdf
ใใใใ็พๅฎไธป็พฉ่
ใฎใใใฎ้ๅญ่ซ.pdf
Introduction_to_Machine_Learning_2024_Edition.pdf
After:
egyptoctwa.pdf
egyptcommu.pdf
quantumphy.pdf
mlintro24.pdf
The tool automatically handles Ollama installation and configuration:
- โ Detects if Ollama is installed
- โ Installs Ollama if missing (macOS/Linux)
- โ Starts Ollama service if not running
- โ Downloads required models automatically
- โ Shows progress during model downloads
pdf_renamer/
โโโ src/
โ โโโ main.rs # CLI and main logic
โ โโโ ollama.rs # Ollama API client
โ โโโ setup.rs # Ollama setup automation
โโโ Cargo.toml
โโโ README.md
cargo testcargo build --releaseContributions 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under a custom license that requires attribution for commercial use - see the LICENSE file for details.
Key points:
- โ Free for personal and commercial use
- โ Can modify and distribute
โ ๏ธ Commercial use requires attribution- โ Non-commercial use doesn't require attribution (but it's appreciated)
Created by Hamzeh Ghalebi (ghalebi@gmail.com)
- Ollama for providing local LLM capabilities
- The Rust community for excellent libraries and tools
- All contributors and users of this project
- Ensure you have
curlinstalled - Check your internet connection
- Try installing Ollama manually from https://ollama.com
- Ensure you have sufficient disk space (models range from 4GB to 10GB)
- Check your internet connection
- Try pulling the model manually:
ollama pull model-name
- Ensure you have write permissions in the PDF directory
- Run with appropriate permissions if needed
- Windows support
- Configuration file support (.pdfrenamer.toml)
- Custom naming patterns and length
- Progress bar for large directories
- Multiple file format support (DOCX, EPUB)
- Parallel processing for faster batch operations
- Undo/restore functionality with history
- Web UI for remote management
If you encounter any issues or have questions, please:
- Check the Issues page
- Create a new issue with details about your problem
- Include your OS, Rust version, and any error messages