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

file-sorter-utility

v1.0.1

Published

A simple utility to sort and rename files in a directory by prefixing them with numbers.

Readme

File Sorter Utility

A simple and flexible command-line tool and library to sort files in a directory and rename them with a numeric prefix.

This tool is perfect for organising media files, documents, or any collection of files where a specific order is desired. It can be run on a folder to perform an initial sort and can also be run again to incrementally add new numbered files without disrupting the existing order.

Key Features

  • Numeric Prefixes: Sorts files alphabetically and adds a zero-padded numeric prefix (e.g., 01_, 02_).
  • Force Re-numbering: An option to strip all existing prefixes and re-number the entire directory.
  • Skip Extensions: Ignore certain file types (e.g., .log, .tmp) during the process.
  • Incremental Mode: Automatically detects existing numbered files and continues numbering from the last number when new files are added.
  • Dual Usage: Can be used as a powerful command-line tool or as a library in your own Node.js projects.

Installation

For command-line use, install the package globally:

npm install -g file-sorter-utility

For use as a library in your own project, install it locally:

npm install file-sorter-utility

CLI Usage

The command is run by specifying a target directory and any desired options.

file-sorter <directory> [options]

Options

| Option | Description | | -------------------- | ------------------------------------------------------------------------------- | | --force | Strips all existing number prefixes and re-numbers the entire directory from 01. | | --skip .ext1,.ext2 | A comma-separated list of file extensions to ignore (e.g., --skip .log,.tmp). |

Examples

1. Basic Sort To sort all files in a folder named my-photos on your desktop:

file-sorter "C:\Users\YourUser\Desktop\my-photos"

2. Incremental Add If my-photos already contains files up to 05_... and you add new files, simply run the same command again. The new files will be numbered starting from 06_....

file-sorter "C:\Users\YourUser\Desktop\my-photos"

3. Force Re-number and Skip Files To re-sort the entire directory from scratch, ignoring .txt and .log files:

file-sorter "C:\Users\YourUser\Desktop\my-photos" --force --skip .txt,.log

Library Usage

You can also use the functions directly in your Node.js code.

const sortAndRenameFiles = require('file-sorter-utility');

const targetDirectory = './path/to/your/files';

// Example 1: Run the main sorting function with options
async function organizeMyFiles() {
  try {
    await sortAndRenameFiles(targetDirectory, {
      force: false,
      skipExtensions: ['.tmp']
    });
    console.log('Done!');
  } catch (error) {
    console.error('An error occurred:', error);
  }
}

organizeMyFiles();

🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📬 Contact

Mathan Kumar - gmathankumar.github.io

Project Link: https://github.com/gmathankumar/file-sorter-utility