asort
Renaming files in ascending order
A package helps renaming files in an ascending order. Each renamed file will contain its own index starting from 1.
Pre-requisite
How to use
It can be used as a dependency or as a CLI directly from your favorite terminal.
To use it as a dependency
npm install --save asort
const { asort } = require('asort');
import asort from 'asort';
To install the CLI
You can choose to either use the CLI directly with npx or to install the CLI globally with NPM.
* Please note that as of npx is bundled with NPM as of the version of 5.2.0.
$ npx asort <command>
$ npm install -g asort
Commands
-
Show help via -h
or --help
.
$ asort -h
-
Show version via -v
or --version
.
$ asort -v
-
Rename files
$ asort ./
$ asort ~/my-videos/
$ asort ~/my-videos/ -l "ja-JP"
$ asort ~/my-videos/ -r "/^(\\S+)[\\s\\S]*?(\\d*)\\.(\\w+)\$/i" -p "\$1 - \$2.\$3"
API reference
asort(dirName[, lang = 'en-US', regex, replace])
dirname
<string> Path to the directory that contains files to be renamed.lang
<string> Language of the files to be renamed. This is needed for sorting the files before renaming. Defaults to en-US
.regex
<string|Regex> Custom RegExp to filter files that need to be renamed.replacer
<string|Function> Custom replacer string or function when renaming the files.
License
MIT License © Rong Sen Ng