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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rename-invoice

v1.0.2

Published

cli util to rename invoice pdf files

Downloads

207

Readme

rename-invoice

npm version npm downloads

A command-line tool to rename invoice PDF files based on their content and name. This tool is particularly useful for organizing and managing invoice files by extracting relevant information such as invoice amount, date, type, and code from the PDF content or filename.

Table of Contents

Features

  • Automatically renames PDF invoices based on extracted data.
  • Supports specific handling for "高德打车电子发票" .
  • Logs operations and errors for better debugging and user experience.
  • Bilingual support in logs (English and Chinese).

Installation

You can use the tool directly without installing it globally by using npx:

npx rename-invoice [directory]

If you prefer to install it globally, run the following command:

npm install -g rename-invoice

Usage

To use the tool, run the following command in your terminal:

npx rename-invoice [directory]

If no directory is specified, the current directory will be used.

How It Works

  1. Directory Scanning: The tool scans the specified directory for PDF files.
  2. Data Extraction: For each PDF file, it attempts to extract the following information:
    • Invoice Amount: Extracted from the file content or filename.
    • Invoice Date: Extracted from the content using regex.
    • Invoice Type: Identified based on predefined labels.
    • Invoice Code: Extracted from the content or generated if not found.
  3. File Renaming: The tool renames the PDF file using the extracted information in the format:
    YYMMDD_InvoiceType_Amount_Code.pdf
  4. Error Handling: If any errors occur during the process, appropriate logs are generated, and users are advised to create an issue on GitHub for assistance.

Examples

Example 1: Renaming a taxi Invoice

If you have a file named 高德打车电子发票-100.00.pdf, running the tool will rename it to something like:

230901_客运发票_100.00_12345678.pdf

Where 230901 is the date in YYMMDD format, 客运发票 is the invoice type, 100.00 is the amount, and 12345678 is a generated code.

Example 2: Renaming Standard Invoices

For a standard invoice PDF, the tool will extract the necessary information and rename it accordingly. If the PDF contains:

发票日期: 2023年09月01日
发票金额: ¥100.00
发票代码: 12345678901234567890

It will be renamed to:

230901_其他发票_100.00_12345678.pdf

Handling Errors

If the tool fails to extract valid data from a PDF, it will log the issue and suggest creating an issue on GitHub for further assistance.

Contributing

Contributions are welcome! If you have suggestions for improvements or find bugs, please create an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.