项目作者: motss

项目描述 :
Renaming files in ascending order
高级语言: JavaScript
项目地址: git://github.com/motss/asort.git
创建时间: 2017-10-14T13:54:42Z
项目社区:https://github.com/motss/asort

开源协议:MIT License

下载


🚨 No longer maintained 🚨


asort



Renaming files in ascending order



Build Status
Version
Downloads
MIT License
Dependency Status
NSP Status
Greenkeeper badge

Code of Conduct

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

  1. # Install it as a dependency in your project
  2. npm install --save asort
  3. # Import the package via 'require'
  4. const { asort } = require('asort'); # OR const asort = require('asort').default;
  5. # Import the package with ES module
  6. 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 @maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b">5.2.0.*

  1. # Use CLI with npx
  2. $ npx asort <command>
  3. # Install globally via NPM
  4. $ npm install -g asort

Commands

  • Show help via -h or --help.

    1. # asort --help
    2. $ asort -h
  • Show version via -v or --version.

    1. # asort --version
    2. $ asort -v
  • Rename files

    1. # Rename files in current directory
    2. $ asort ./
    3. # Rename files with defined directory path
    4. $ asort ~/my-videos/
    5. # Rename files with defined language for sorting files before renaming
    6. $ asort ~/my-videos/ -l "ja-JP"
    7. # Rename files with RegExp + replacer function
    8. $ 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