1 | # filenamify [![Build Status](https://travis-ci.org/sindresorhus/filenamify.svg?branch=master)](https://travis-ci.org/sindresorhus/filenamify)
|
2 |
|
3 | > Convert a string to a valid filename
|
4 |
|
5 | On Unix-like systems `/` is reserved and [`<>:"/\|?*`](http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29#naming_conventions) on Windows.
|
6 |
|
7 |
|
8 | ## Install
|
9 |
|
10 | ```
|
11 | $ npm install --save filenamify
|
12 | ```
|
13 |
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | var filenamify = require('filenamify');
|
19 |
|
20 | filenamify('<foo/bar>');
|
21 | //=> foo!bar
|
22 |
|
23 | filenamify('foo:"bar"', {replacement: '🐴'});
|
24 | //=> foo🐴bar
|
25 | ```
|
26 |
|
27 |
|
28 | ## API
|
29 |
|
30 | ### filenamify(input, options)
|
31 |
|
32 | #### input
|
33 |
|
34 | *Required*
|
35 | Type: `string`
|
36 |
|
37 | String you want to use as a filename.
|
38 |
|
39 | #### options
|
40 |
|
41 | ##### replacement
|
42 |
|
43 | Type: `string`
|
44 | Default: `'!'`
|
45 |
|
46 | String to use as replacement for reserved filename characters.
|
47 |
|
48 | Cannot contain: `<` `>` `:` `"` `/` `\` `|` `?` `*`
|
49 |
|
50 |
|
51 | ## Related
|
52 |
|
53 | - [`filenamify-url`](https://github.com/sindresorhus/filenamify-url) - Convert a URL to a valid filename
|
54 | - [`valid-filename`](https://github.com/sindresorhus/valid-filename) - Check if a string is a valid filename
|
55 |
|
56 |
|
57 | ## License
|
58 |
|
59 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|