An open API service indexing awesome lists of open source software.

https://github.com/webcaetano/filename-to-dir

Use filenames to create folders schema
https://github.com/webcaetano/filename-to-dir

Last synced: 6 months ago
JSON representation

Use filenames to create folders schema

Awesome Lists containing this project

README

          

# filename-to-dir

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]

> Use filenames to create folders schema.

## Installation

```
npm install filename-to-dir --save
```

## Usage

```
namedir(glob,dest,options,callback)
```

## Example

```javascript
var namedir = require('filename-to-dir');

namedir('**/*.png','./destFolder',function(){

});

// this
// heroes_$_lulu_$_hit_$_001.png
// heroes_$_lulu_$_hit_$_002.png
// heroes_$_janna_$_walk_$_001.png

// return
// destFolder/heroes/lulu/hit/001.png
// destFolder/heroes/lulu/hit/002.png
// destFolder/heroes/janna/walk/001.png

// or
namedir(['**/*.png'],'./destFolder',{split:'@'},function(){

});

// with all options
namedir(['**/*.png'],'./destFolder',{split:'@'},function(err,data){

});
```

## Options

Option
Description
Default

split
Split string.
_$_

## CLI

```
npm install filename-to-dir -g
```

```
Usage
$ namedir

Options
--split Split string. Default: "_$_"

Examples
namedir "**/*.png"
namedir "**/*.png" destFolder/
namedir "**/*.png" "destFolder/" --split "@"
```

## Check Also

[flatten-dirname](https://github.com/webcaetano/flatten-dirname)

## License

MIT

[npm-image]: https://img.shields.io/npm/v/filename-to-dir.svg?style=flat-square
[npm-url]: https://npmjs.org/package/filename-to-dir
[travis-image]: https://img.shields.io/travis/webcaetano/filename-to-dir.svg?style=flat-square
[travis-url]: https://travis-ci.org/webcaetano/filename-to-dir