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-them-all

v0.1.0

Published

CLI tool for easy renaming multiple files in current directory

Downloads

3

Readme

version

rename-them-all

CLI tool written in node.js for renaming multiple files at once. It can:

  • rename files using template
  • add suffixes and prefixes
  • add dimensions in file name for images
  • add size range as suffix or prefix
  • rename files with a specific extension
  • rename files by groups like images, docs, audio, video

This is a tool I wrote for myself, but I wanted to share it. So here it is. I use it for archiving my files or managing image files.

Install


npm install -g rename-them-all

Install rename-them-all globally, then you can call it from any directory in your console.

Usage

Caution! The outcome of executing this program is irreversible!

Renaming files
// let's say we have such files in our directory:
// bull.txt, cat.txt, dog.jpeg, mouse.pdf


$ rename-them-all "example_[###]"

// output: example_001.txt, example_002.txt, example_003.jpeg, example_004.pdf

[###] - index template is mandatory in your new file name

index template options:

[#] --> 1
[##] --> 01
[###] --> 001

Adding prefix or suffix

To add a prefix or suffix set -p, -s or both.
This method doesn't work with renaming files.

// files in our directory:
// bull.txt, cat.txt, dog.jpeg, mouse.pdf



$ rename-them-all -p=examplePrefix_        <--- Prefix

// output: examplePrefix_bull.txt, examplePrefix_cat.txt ...



$ rename-them-all -s=_exampleSuffix       <--- Suffix

// output: bull_exampleSuffix.txt, cat_exampleSuffix.txt ...



$ rename-them-all -p=examplePrefix_ -s=_exampleSuffix       <--- Both

// output: examplePrefix_bull_exampleSuffix.txt, examplePrefix_cat_exampleSuffix.txt ...

Choose extension type

To choose extension type for files set -t flag

// files in our directory: 
// bull.txt, cat.txt, dog.jpeg, mouse.pdf 


$ rename-them-all "example_[###]" -t=jpeg       <--- Renaming files

// output: bull.txt, cat.txt, example_001.jpeg, mouse.pdf


$ rename-them-all -p=example_ -t=jpeg       <--- Prefix / Suffix

// output: bull.txt, cat.txt, example_dog.jpeg, mouse.pdf

Choose type group

To choose a type group set -g flag. Possible options: images | docs | audio | video

// files in our directory: 
// bull.txt, cat.txt, dog.jpeg, mouse.pdf 


$ rename-them-all "example_[###]" -g=docs

// output: example_001.txt, example_002.txt, dog.jpeg, example_003.pdf

Type groups:

images: ['jpeg', 'jpg', 'png', 'bmp', 'tiff', 'gif'],
docs: ['txt', 'doc', 'docs', 'pdf', 'epub', 'mobi'],
audio: ['mp3', 'wav', 'mpeg4', 'flac', 'ogg'],
video: ['avi', 'mp4', 'mkv']

Note: there will be more


Adding image dimensions

You can add image dimensions to your file name using image size template. Works with renaming files only. You have to set -g flag to images.

// files in our directory: 
// bull.txt, cat.txt, dog.jpeg, mouse.pdf 


$ rename-them-all "example_[##]_[wh]" -g=images

// output: bull.txt, cat.txt, example_01_200x300.jpeg, example_003.pdf

You can print dimensions differently:
[wh] is a image size template w stands for width h stands form height

[w] renders only width
[h] renders only height
[wh] renders width then height
[hw] renders height then width

Note: For this moment you can use only one image size template in a file name


Adding image size range name

You can add suffix or prefix with a size range name for images. Set -i flag. You can use it only with -s or -p flag. Also setting -g to images is mandatory.

// files in our directory: 
// bull.txt, cat.txt, dog.jpeg, mouse.pdf 
// let's say that dog.jpeg dimensions are 200x200

$ rename-them-all -s -i -g=images       <--- Suffix

// Output: bull.txt, cat.txt, dog_small.jpeg ...

$ rename-them-all -p -i -g=images		<--- Prefix

// Output: bull.txt, cat.txt, small_dog.jpeg ...

Here are the available ranges based on image resolution:

small: 1px - 122500px,
medium: 122501px - 840000px,
large: 840001px - Infinity

Links

  • NPM: https://www.npmjs.com/package/rename-them-all

  • Repository: https://github.com/EmilTheSadCat/rename-them-all

Licensing

The code in this project is licensed under ISC license.