# npm-max-dir-index

> This package is created for separation of the logic for finding a highest number in file's name in a directory by regular expression.

Latest version **1.0.4** (published 2016-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-max-dir-index
pnpm add npm-max-dir-index
yarn add npm-max-dir-index
bun add npm-max-dir-index
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2016-03-03 |
| First published | 2016-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Georgi Naumov |
| Maintainers | gonaumov |
| Keywords | directory |

## Links

- npm: https://www.npmjs.com/package/npm-max-dir-index
- Repository: https://github.com/gonaumov/npm-max-dir-index
- Homepage: https://github.com/gonaumov/npm-max-dir-index#readme
- Issues: https://github.com/gonaumov/npm-max-dir-index/issues
- npm.io page: https://npm.io/package/npm-max-dir-index

## Dependencies (1)

- [sf](https://npm.io/package/sf.md) ^0.1.8

## Recent versions

- 1.0.4 (latest) — 2016-03-03
- 1.0.3 — 2016-03-02
- 1.0.2 — 2016-03-01
- 1.0.1 — 2016-03-01
- 1.0.0 — 2016-03-01

## README

This package is created for separation of the logic for finding a highest number in file's name 
in a directory by regular expression. For example, when in a directory there are  
the following files: 1.txt, 2.text, as a result of calling the function like this:
```
dirIndex('testDir/','^([0-9]+)\.txt$')
```
we will receive 3. 
The function accepts two arguments. The first one is a string - a path to directory. 
The second one must be a regular expression that must have a number as a first backreference. 
If your directory's structure is like this:
```
testDir$ tree -f
.
├── ./1.txt
├── ./2.txt
├── ./3.txt
└── ./4.txt

0 directories, 4 files
```

the below code will return for you 5. 

```
var dirIndex = require('npm-max-dir-index');

console.log(dirIndex('testDir/','^([0-9]+)\.txt$'));
```


If your directory's structure is like this:
```
test1$ tree 
.
├── image1.png
├── image2.png
├── image3.png
└── image4.png

0 directories, 4 files
```


the below code will return for you 5. 

```
var dirIndex = require('npm-max-dir-index');

console.log(dirIndex('test1/','^image([0-9]+)\.png$'));
```

For more information check this
stackoverflow answer: 
[http://stackoverflow.com/questions/34989297/gulp-rename-files-with-ordinal-numbers-starting-index-from-the-higest-number-i/34991039#34991039](http://stackoverflow.com/questions/34989297/gulp-rename-files-with-ordinal-numbers-starting-index-from-the-higest-number-i/34991039#34991039)

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