https://github.com/electerious/rename-extension
Changes the the extension of a given filename or path.
https://github.com/electerious/rename-extension
extension file file-explorer rename
Last synced: about 2 months ago
JSON representation
Changes the the extension of a given filename or path.
- Host: GitHub
- URL: https://github.com/electerious/rename-extension
- Owner: electerious
- License: mit
- Created: 2016-04-22T21:26:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-10-01T13:59:11.000Z (almost 3 years ago)
- Last Synced: 2025-04-27T17:03:53.686Z (3 months ago)
- Topics: extension, file, file-explorer, rename
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rename-extension
 [](https://coveralls.io/github/electerious/rename-extension?branch=master)
A function that changes the the extension of a given filename or path.
## Install
```
npm install rename-extension
```## Usage
```js
const renameExtension = require('rename-extension')renameExtension('a/b/c.js', null) // a/b/c
renameExtension('a/b/c.js', '.css') // a/b/c.css
renameExtension('a/b/c.min.js', '.css') // a/b/c.min.css
renameExtension('a/b/.npmrc', null) // a/b/.npmrc
renameExtension('a/b/.npmrc', '.json') // a/b/.npmrc.json
```## API
### Parameters
- `filePath` `{String}` Path to a file.
- `newExt` `{String}` New extension for the file.### Returns
- `filePath` `{String}` Path ending with the new extension.