/filenamify

Convert a string to a valid safe filename

Primary LanguageJavaScriptMIT LicenseMIT

filenamify Build Status

Convert a string to a valid safe filename

On Unix-like systems / is reserved and <>:"/\|?* on Windows.

Install

$ npm install filenamify

Usage

const filenamify = require('filenamify');

filenamify('<foo/bar>');
//=> 'foo!bar'

filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'

API

filenamify(string, [options])

Convert a string to a valid filename.

filenamify.path(path, [options])

Convert the filename in a path a valid filename and return the augmented path.

options

Type: Object

replacement

Type: string
Default: '!'

String to use as replacement for reserved filename characters.

Cannot contain: < > : " / \ | ? *

Related

License

MIT © Sindre Sorhus