# ntransformer

> Change all substrings of directory names, file names and file content

Latest version **1.0.5** (published 2020-07-01) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2020-07-01 |
| First published | 2020-06-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Sagynbek Kenzhebaev |
| Maintainers | sagynbek |
| Keywords | transform, update, change, name, file, directory, folder |

## Links

- npm: https://www.npmjs.com/package/ntransformer
- Repository: https://github.com/sagynbek/ntransform
- Homepage: https://github.com/sagynbek/ntransform#readme
- Issues: https://github.com/sagynbek/ntransform/issues
- npm.io page: https://npm.io/package/ntransformer

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.5 (latest) — 2020-07-01
- 1.0.4 — 2020-06-27
- 1.0.3 — 2020-06-27
- 1.0.2 — 2020-06-26
- 1.0.1 — 2020-06-26

## README

# ntransformer

This package can help you to change substrings of directory names, file names and file content. 
Also it does it recursively, so you can change all occurences under certain directory.

Written purely using TypeScript, so it's strongly typed

All function have config parameter `maxDepth` which control depth of recursion


> Run `npm i ntransformer` to install package

___

### Changing file names:
Changes `searchKey` with `replaceKey` in file names under `path` recursively

> Example use of **updateFileNames**

```javascript
const ntransformer = require("ntransformer");

ntransformer.updateFileNames({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder")
})
```

| Config                      | Values                                            | Required    | Description                           | 
| -------------               | ----------------------                            | :---------: | ----------------------                | 
| path                        | string (Default = **__dirname**)                  | No          | absolute path                         |
| searchKey                   | string \| RegExp (case sensitive)                 | Yes         | search key substring                  |
| replaceKey                  | string                                            | Yes         | replace key                           |
| maxDepth                    | number (Default = **10**)                         | No          | maximum recursion depth               |


![Application image](./images/file-name-demo.gif?raw=true)

___

### Changing directory names:

Changes `searchKey` with `replaceKey` in directory names under `path` recursively

> Example use of **updateDirectoryNames**

```javascript
const ntransformer = require("ntransformer");

ntransformer.updateDirectoryNames({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder")
})
```

| Config                      | Values                                            | Required    | Description                           | 
| -------------               | ----------------------                            | :---------: | ----------------------                | 
| path                        | string (Default = **__dirname**)                  | No          | absolute path                         |
| searchKey                   | string \| RegExp (case sensitive)                 | Yes         | search key substring                  |
| replaceKey                  | string                                            | Yes         | replace key                           |
| maxDepth                    | number (Default = **10**)                         | No          | maximum recursion depth               |

![Application image](./images/directory-name-demo.gif?raw=true)

___

### Replacing file contents:

Replaces `searchKey` with `replaceKey` in all allowed (by extensions) files under `path` recursively

> Example use of **updateFileContent**

```javascript
const ntransformer = require("ntransformer");

ntransformer.updateFileContent({ 
  searchKey: 'searchkey',
  replaceKey: 'replaceKey',
  path: path.join(__dirname, "target-folder"),
  permittedFileExtensions: [".txt", ".js", ".ts", ".json"]
})
```

| Config                      | Values                                                              | Required    | Description                           | 
| -------------               | ----------------------                                              | :---------: | ----------------------                | 
| path                        | string (Default = **__dirname**)                                    | No          | absolute path                         |
| searchKey                   | string \| RegExp (case sensitive)                                   | Yes         | search key substring                  |
| replaceKey                  | string                                                              | Yes         | replace key                           |
| maxDepth                    | number (Default = **10**)                                           | No          | maximum recursion depth               |
| permittedFileExtensions     | Array of string (Default = **[".txt", ".js", ".ts", ".json"]**)     | No          | maximum recursion depth               |

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