# patrename

> A Pattern-based file bulk rename utility

Latest version **0.1.1** (published 2014-11-28) · 0 weekly downloads

## Install

```sh
npm install patrename
pnpm add patrename
yarn add patrename
bun add patrename
```

Provides the command `patrename`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-11-28 |
| First published | 2014-11-28 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.4 |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | YC |
| Maintainers | yc |
| Keywords | file, rename, pattern |

## Links

- npm: https://www.npmjs.com/package/patrename
- Repository: git@github.com:yinso/patrename
- Homepage: https://github.com/yinso/patrename
- Issues: https://github.com/yinso/patrename/issues
- npm.io page: https://npm.io/package/patrename

## Dependencies (7)

- [yargs](https://npm.io/package/yargs.md) =1.3.3
- [loglet](https://npm.io/package/loglet.md) >=0.1.1
- [filelet](https://npm.io/package/filelet.md) >=0.1.1
- [funclet](https://npm.io/package/funclet.md) >=0.1.0
- [makelet](https://npm.io/package/makelet.md) >=0.1.1
- [underscore](https://npm.io/package/underscore.md) =1.7.0
- [coffee-script](https://npm.io/package/coffee-script.md) =1.7.1

## Recent versions

- 0.1.1 (latest) — 2014-11-28

## README

# `patrename` - a pattern-based file bulk rename utility.

## Install

    npm install -g patrename
    
## Usage

    patrename [-y|--dryRun] <source_path_pattern> [<replace_pattern>]

`patrename` utilizes Javascript regular expressions to match files - you can test to see how the regular expression matches by not supplying the `<replace_pattern>`:

    $ patrename 'test_(\d+).png' # matches all files in the current directory that matches the expression. 
    matched files: 
    [ 'test_01.png',
      'test_02.png',
      ...
    ]
    supply replacement pattern to rename them.

`-y` or `--dryRun` will allow you to test out your replacement pattern without actually rename the files.

The replacement pattern is done as a [`CoffeeScript`](http://coffeescript.org) interpolated string, with the matched pattern named as `$1`, `$2`, `$3`, etc.

For example, if the goal is to strip the `test_` prefix from the file name, we just supply `#{$1}.png` as the replacement string.

    $ patrename 'test_(\d+).png' '#{$1}.png'

One thing to keep in mind is that in shells that use `$` as variable prefixes, double quote strings will require an escape with `\`. I.e., 

    '#{$1}.png'

or

    "#{\$1}.png"

A couple of utility functions are supplied - `incr` will increment the number, and `descr` will decrement the number.

    $ patrename 'test_(\d+).png' '#{incr($1)}.png'
    # will rename test_1.png to 2.png, etc.

---
_Source: https://npm.io/package/patrename · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
