npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hugomrdias/receipts

v1.0.6

Published

CLI to extract data from receipts/invoices and rename files (PDFs & images) using AI SDK

Readme

file-renamer

CLI to scan a folder of receipts/invoices (PDFs and images), extract structured data using AI, and rename files to a consistent pattern.

What it does

  • Detects file type (PDF or image)
  • Sends the raw file directly to Gemini (no local OCR), extracts: dateISO, issuer, totalAmount, currency, docType
  • Renames to: YYYY-MM-DD__ISSUER.ext
  • Handles name collisions by appending -001, -002, ...

Requirements

  • Node 20+
  • pnpm 10+
  • Google Generative AI key in GOOGLE_GENERATIVE_AI_API_KEY

Install

pnpm install

No local OCR components required.

Usage

Set your API key, then run:

GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- --help

Common flows:

# Dry-run, current directory
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- -n

# Process a folder recursively (no changes, just preview)
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- ~/Downloads/receipts -r -n

# Actually rename, only PDFs and JPGs
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- ~/Downloads/receipts -r --include-ext pdf jpg

# Write renamed files into a separate directory
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- ~/Downloads/receipts -r --out-dir ~/Desktop/renamed

# Increase concurrency
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- ~/Downloads/receipts -r --concurrency 8

# Fail fast on first error
GOOGLE_GENERATIVE_AI_API_KEY=AIza... pnpm start -- ~/Downloads/receipts --fail-on-error

You can also link the CLI globally if you prefer:

pnpm link -g
GOOGLE_GENERATIVE_AI_API_KEY=AIza... file-renamer ~/Downloads/receipts -r -n

Options

file-renamer [dir]

Arguments:
  dir                     Directory to process (default: ".")

Options:
  -r, --recursive         Process directories recursively (default: false)
  -n, --dry-run           Do not rename, only show planned actions (default: false)
  --fail-on-error         Exit non-zero on first failure (default: false)
  --include-ext <ext...>  Only process listed extensions (e.g., pdf jpg png)
  --exclude-ext <ext...>  Exclude listed extensions
  --concurrency <n>       Concurrent files processed (default: 3)
  --out-dir <dir>         Write renamed files into this directory (defaults to same dir)
  -h, --help              display help for command

How it works (brief)

  • Type sniffing via file-type
  • OCR/text extraction
    • PDF text via pdf-parse
    • Image OCR via tesseract.js
  • AI extraction using AI SDK + Google Gemini (gemini-2.5-flash) and a Zod schema for structured output
  • Filename builder
    • YYYY-MM-DD__ISSUER.ext
    • Issuer sanitized to be filesystem-safe and trimmed to 30 chars
    • Collisions resolved by appending -001, -002, ...

Notes & limits

  • OCR quality varies; low-quality scans may need manual review
  • LLM extraction is best-effort; it normalizes date to yyyy-mm-dd and shortens issuer names
  • AI calls are remote (OpenAI). OCR is local.

License

ISC