whatisgithub

What is classify-filename?

elizabethsobiya/classify-filename — explained in plain English

Analysis updated 2026-05-18

4TypeScriptAudience · developerComplexity · 1/5LicenseSetup · easy

In one sentence

A tiny library that sorts a list of filenames into named groups based on text, pattern, or custom matching rules.

Mindmap

mindmap
  root((repo))
    What it does
      Sorts filenames into buckets
      Supports string regex function rules
      Natural sort within buckets
    Tech stack
      TypeScript
      Zero dependencies
      npm package
    Use cases
      Organize uploaded documents
      Batch sort files by pattern
      Debug matching with explain
    Audience
      Developers
      Automation builders

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically sort uploaded documents into folders like invoices, contracts, and agreements.

USE CASE 2

Group a batch of files by naming pattern before processing them further.

USE CASE 3

Debug why a file landed in a particular bucket using the explain option.

USE CASE 4

Replace custom filename sorting logic with a single reusable function.

What is it built with?

TypeScriptNode.js

How does it compare?

elizabethsobiya/classify-filename0labs-in/vision-linkadarsh-me/image-sdk
Stars444
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasymoderateeasy
Complexity1/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

classify-filename is a small JavaScript and TypeScript library that takes a list of filenames and sorts them into named groups based on rules you define. Instead of writing your own logic every time you need to organize files by name, you hand it a list of filenames and a list of buckets, and it puts each file into the right bucket. Each bucket has a name and a rule for matching filenames to it. A rule can be a plain piece of text to search for inside the filename, a regular expression pattern, or your own custom function that checks the filename however you like. You can also combine several of these rule types together for one bucket. The order of your buckets matters: the first bucket whose rule matches a filename is the one that file goes into, so you should put your narrowest, most specific rules first and your broader, catch-all rules last. Files that do not match any bucket land in a default group called uncategorized, though you can change that name or turn it off entirely. The library also supports putting a single file into more than one bucket if you want that behavior, and it sorts the filenames within each bucket in a way that treats numbers naturally, so a file numbered 2 comes before one numbered 10. There is also a debugging option that shows you exactly which bucket each filename was matched to and why. The project has no external dependencies and is installed through npm. The author positions it as a small, focused replacement for writing the same file sorting logic by hand every time, since a basic filter only gives you one group at a time rather than multiple named, prioritized buckets with a fallback. As of this version it does not support glob patterns or sorting by file size or date, and it has no command line interface, only use as a code library. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
Help me install classify-filename and write rules to sort my files into invoices, contracts, and misc buckets.
Prompt 2
Show me how to use a regular expression matcher in classify-filename to catch filenames with different cases.
Prompt 3
Explain how bucket order affects matching priority in classify-filename and help me reorder my rules correctly.
Prompt 4
Walk me through using the explain option in classify-filename to debug why a file was miscategorized.

Frequently asked questions

What is classify-filename?

A tiny library that sorts a list of filenames into named groups based on text, pattern, or custom matching rules.

What language is classify-filename written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js.

What license does classify-filename use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is classify-filename to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is classify-filename for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.