Crates.io | papersmith |
lib.rs | papersmith |
version | 0.5.0 |
source | src |
created_at | 2025-05-06 10:50:26.463465+00 |
updated_at | 2025-05-14 00:21:26.780226+00 |
description | AI-Powered PDF Renamer in Rust. |
homepage | https://github.com/benletchford/papersmith |
repository | https://github.com/benletchford/papersmith |
max_upload_size | |
id | 1662210 |
size | 88,048 |
An AI-powered PDF renamer that uses OpenAI's models (e.g., gpt-4o
, gpt-4.1
) via the /v1/responses
API to intelligently rename PDF documents based on their content. Papersmith analyzes your PDFs by sending them directly to the API and generates descriptive filenames that include the document date, category, and title.
/v1/responses
API along with a prompt asking for document details.YYYYMMDD-title-category.pdf
.^\d{8}.*\.pdf$
).Ensure you have Rust installed (rustup.rs).
cargo install papersmith # or cargo binstall papersmith
After installing papersmith
, you need to set the following environment variables for the application to function correctly:
PAPERSMITH_OPENAI_API_KEY
: Your OpenAI API key. This is required.PAPERSMITH_GLOB_PATTERN
(optional): A default glob pattern for PDF files (e.g., "./my_pdfs/**/*.pdf"
). If this is not set and the command-line argument --glob-pattern
(or -g
) is not provided at runtime, the application will return an error.You can set these variables in your shell's configuration file (e.g., .bashrc
, .zshrc
) or export them in the terminal session where you run papersmith
.
# Basic usage (processes PDFs based on PAPERSMITH_GLOB_PATTERN or an error if not set)
papersmith
# Process PDFs in a specific directory (overrides PAPERSMITH_GLOB_PATTERN if set)
papersmith --glob-pattern "./invoices/*.pdf"
# Preview changes without renaming files
papersmith --dry-run
# Specify a compatible OpenAI model (e.g., gpt-4o, gpt-4.1)
papersmith --model gpt-4o
-g, --glob-pattern <PATTERN>
: Glob pattern to specify which PDFs to process. If not provided, the PAPERSMITH_GLOB_PATTERN
environment variable is used. If neither is set, it's an error.-m, --model <MODEL>
: Choose the OpenAI model to use (default: "gpt-4o-mini", but ensure the chosen model is compatible with the /v1/responses
endpoint for direct PDF processing, like gpt-4o
or gpt-4.1
).-d, --dry-run
: Preview changes without renaming files.-h, --help
: Display help information.-V, --version
: Display version information.For example:
Scanned Document 1.pdf
→ 20240916-bunnings-invoice.pdf
Document.pdf
→ 20231225-unknown-document.pdf
Run these commands in the project root directory:
# Debug build
cargo build
# Release build
cargo build --release
This project is open source and available under the MIT License.