{"_id":"strip-filename-increment","_rev":"87195","name":"strip-filename-increment","description":"Operating systems commonly add a trailing increment, or the word 'copy', or something similar to duplicate files. This strips those increments. Tested on Windows, MacOS, and Linux.","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:28:21.000Z","created":"2017-07-02T06:29:02.413Z","2.0.1":"2019-09-04T05:35:05.330Z","2.0.0":"2019-09-04T05:03:36.765Z","1.0.0":"2017-07-11T05:28:17.923Z","0.1.0":"2017-07-02T06:29:02.413Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"versions":{"2.0.1":{"name":"strip-filename-increment","description":"Operating systems commonly add a trailing increment, or the word 'copy', or something similar to duplicate files. This strips those increments. Tested on Windows, MacOS, and Linux.","version":"2.0.1","homepage":"https://github.com/jonschlinkert/strip-filename-increment","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT","main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^2.0.0","mocha":"^6.2.0"},"keywords":["filename","increment","strip"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"c4573f5b2d6b5c3a1ea7b062a3e82d3bf4371277","_id":"strip-filename-increment@2.0.1","_nodeVersion":"12.7.0","_npmVersion":"6.10.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"3feca2ebd529d4cdcad0281a9bbb2660b096fcc6","size":4382,"noattachment":false,"key":"/strip-filename-increment/-/strip-filename-increment-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/strip-filename-increment/download/strip-filename-increment-2.0.1.tgz"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment_2.0.1_1567575305180_0.26608270137155454"},"_hasShrinkwrap":false,"publish_time":1567575305330,"_cnpm_publish_time":1567575305330},"2.0.0":{"name":"strip-filename-increment","description":"Operating systems commonly add a trailing increment, or the word 'copy', or something similar to duplicate files. This strips those increments. Tested on Windows, MacOS, and Linux.","version":"2.0.0","homepage":"https://github.com/jonschlinkert/strip-filename-increment","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT","main":"index.js","engines":{"node":">=8"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^2.0.0","mocha":"^6.2.0"},"keywords":["filename","increment","strip"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"e1f652a69e4222a168dc43f327abc1f6cbba71db","_id":"strip-filename-increment@2.0.0","_nodeVersion":"12.7.0","_npmVersion":"6.10.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"dist":{"shasum":"0f196db60ccfbe9b6dbfea9b7c2c39c1004f570f","size":3882,"noattachment":false,"key":"/strip-filename-increment/-/strip-filename-increment-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/strip-filename-increment/download/strip-filename-increment-2.0.0.tgz"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment_2.0.0_1567573416607_0.467487575351742"},"_hasShrinkwrap":false,"publish_time":1567573416765,"_cnpm_publish_time":1567573416765},"1.0.0":{"name":"strip-filename-increment","description":"Strips the numerical increment and/or the word `copy` that is automatically generated and added to the end of a filename by an operating system. Works with windows and mac-OS style increments. Useful when it's necessary to normalize filenames for doing fi","version":"1.0.0","homepage":"https://github.com/jonschlinkert/strip-filename-increment","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=4"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^3.4.2"},"keywords":["filename","increment","strip"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"gitHead":"da93e03b080599d145a1ded106ba8bdd50ba039c","_id":"strip-filename-increment@1.0.0","_npmVersion":"5.2.0","_nodeVersion":"7.7.3","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"3e33c3cfce28cfda639c421745087facf6194f7a","size":2564,"noattachment":false,"key":"/strip-filename-increment/-/strip-filename-increment-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/strip-filename-increment/download/strip-filename-increment-1.0.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment-1.0.0.tgz_1499750896975_0.5705821004230529"},"directories":{},"publish_time":1499750897923,"_hasShrinkwrap":false,"_cnpm_publish_time":1499750897923},"0.1.0":{"name":"strip-filename-increment","description":"Strips the numerical increment and/or the word `copy` that is automatically generated and added to the end of a filename by an operating system Works with windows and mac-OS style increments. Useful for doing file comparisons, looking for dupes, etc.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/strip-filename-increment","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=4"},"scripts":{"test":"mocha"},"devDependencies":{"gulp-format-md":"^1.0.0","mocha":"^3.4.2"},"keywords":["filename","increment","strip"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"lint":{"reflinks":true}},"_id":"strip-filename-increment@0.1.0","_npmVersion":"5.0.4","_nodeVersion":"7.7.3","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"0a774eef947b4242cf3dff46e63f03ff55921a29","size":2540,"noattachment":false,"key":"/strip-filename-increment/-/strip-filename-increment-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/strip-filename-increment/download/strip-filename-increment-0.1.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment-0.1.0.tgz_1498976941414_0.707336179446429"},"directories":{},"publish_time":1498976942413,"_hasShrinkwrap":false,"_cnpm_publish_time":1498976942413}},"readme":"# strip-filename-increment [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/strip-filename-increment.svg?style=flat)](https://www.npmjs.com/package/strip-filename-increment) [![NPM monthly downloads](https://img.shields.io/npm/dm/strip-filename-increment.svg?style=flat)](https://npmjs.org/package/strip-filename-increment) [![NPM total downloads](https://img.shields.io/npm/dt/strip-filename-increment.svg?style=flat)](https://npmjs.org/package/strip-filename-increment) [![Build Status](https://travis-ci.org/jonschlinkert/strip-filename-increment.svg?branch=master)](https://travis-ci.org/jonschlinkert/strip-filename-increment)\n\n> Operating systems commonly add a trailing increment, or the word 'copy', or something similar to duplicate files. This strips those increments. Tested on Windows, MacOS, and Linux.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=8):\n\n```sh\n$ npm install --save strip-filename-increment\n```\n\n## Usage\n\n```js\nconst strip = require('strip-filename-increment');\n```\n\n## API\n\n### [strip](index.js#L34)\n\nRemove trailing increments from the `dirname` and/or `stem` (basename\nwithout extension) of the given file path or object.\n\n**Params**\n\n* `file` **{Sring|Object}**: If the file is an object, it must have a `path` property.\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String|Object}**: Returns the same type that was given.\n\n### [.increment](index.js#L62)\n\nRemoves trailing increments from the given string.\n\n**Params**\n\n* `input` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**\n\n**Example**\n\n```js\nconsole.log(strip.increment('foo (2)')); => 'foo'\nconsole.log(strip.increment('foo (copy)')); => 'foo'\nconsole.log(strip.increment('foo copy 2')); => 'foo'\n```\n\n### [.dirname](index.js#L86)\n\nRemoves trailing increments and returns the `dirname` of the given `filepath`.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**: Returns the `dirname` of the filepath, without increments.\n\n**Example**\n\n```js\nconsole.log(strip.dirname('foo (2)/bar.txt')); => 'foo'\nconsole.log(strip.dirname('foo (copy)/bar.txt')); => 'foo'\nconsole.log(strip.dirname('foo copy 2/bar.txt')); => 'foo'\n```\n\n### [.stem](index.js#L107)\n\nRemoves trailing increments and returns the `stem` of the given `filepath`.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**: Returns the `stem` of the filepath, without increments.\n\n**Example**\n\n```js\nconsole.log(strip.stem('foo/bar (2).txt')); //=> 'bar'\nconsole.log(strip.stem('foo/bar (copy).txt')); //=> 'bar'\nconsole.log(strip.stem('foo/bar copy 2.txt')); //=> 'bar'\nconsole.log(strip.stem('foo/bar (2) copy.txt')); //=> 'bar'\nconsole.log(strip.stem('foo/bar (2) - copy.txt')); //=> 'bar'\n```\n\n### [.basename](index.js#L128)\n\nRemoves trailing increments and returns the `basename` of the given `filepath`.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**: Returns the `basename` of the filepath, without increments.\n\n**Example**\n\n```js\nconsole.log(strip.basename('foo/bar (2).txt')); //=> 'bar.txt'\nconsole.log(strip.basename('foo/bar (copy).txt')); //=> 'bar.txt'\nconsole.log(strip.basename('foo/bar copy 2.txt')); //=> 'bar.txt'\nconsole.log(strip.basename('foo/bar (2) copy.txt')); //=> 'bar.txt'\nconsole.log(strip.basename('foo/bar (2) - copy.txt')); //=> 'bar.txt'\n```\n\n### [.path](index.js#L151)\n\nRemoves trailing increments from the `dirname` and `stem` of the given `filepath`.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**: Returns the `basename` of the filepath, without increments.\n\n**Example**\n\n```js\nconsole.log(strip.path('foo copy/bar (2).txt')); //=> 'foo/bar.txt'\nconsole.log(strip.path('foo (2)/bar (copy).txt')); //=> 'foo/bar.txt'\nconsole.log(strip.path('foo (2)/bar copy 2.txt')); //=> 'foo/bar.txt'\nconsole.log(strip.path('foo copy/bar (2) copy.txt')); //=> 'foo/bar.txt'\nconsole.log(strip.path('foo copy/bar (2) - copy.txt')); //=> 'foo/bar.txt'\n```\n\n### [.file](index.js#L181)\n\nRemoves trailing increments from the `dirname` and `stem` properties of the given `file`.\n\n**Params**\n\n* `filepath` **{String}**\n* `options` **{Object}**: See [available options](#options).\n* `returns` **{String}**: Returns the `basename` of the filepath, without increments.\n\n**Example**\n\n```js\nconsole.log(strip({ path: 'foo copy/bar (2).txt' }));\n//=> { path: 'foo/bar.txt', dir: 'foo', base: 'bar.txt', name: 'bar', ext: '.txt' }\nconsole.log(strip({ path: 'foo (2)/bar (copy).txt' }));\n//=> { path: 'foo/bar.txt', dir: 'foo', base: 'bar.txt', name: 'bar', ext: '.txt' }\nconsole.log(strip({ path: 'foo (2)/bar copy 2.txt' }));\n//=> { path: 'foo/bar.txt', dir: 'foo', base: 'bar.txt', name: 'bar', ext: '.txt' }\nconsole.log(strip({ path: 'foo copy/bar (2) copy.txt' }));\n//=> { path: 'foo/bar.txt', dir: 'foo', base: 'bar.txt', name: 'bar', ext: '.txt' }\nconsole.log(strip({ path: 'foo copy/bar (2) - copy.txt' }));\n//=> { path: 'foo/bar.txt', dir: 'foo', base: 'bar.txt', name: 'bar', ext: '.txt' }\n```\n\n## Options\n\n### removeRawNumbers\n\nRemove \"raw\" trailing numbers that might not actually be increments. Use this with caution.\n\n**Type**: `boolean`\n\n**Default**: `undefined`\n\n**Example**:\n\n```js\nconsole.log(strip('foo 1')); //=> 'foo 1'\nconsole.log(strip('foo 1', { removeRawNumbers: true })); //=> 'foo'\n\nconsole.log(strip('foo (1) 1')); //=> 'foo (1) 1'\nconsole.log(strip('foo (1) 1', { removeRawNumbers: true })); //=> 'foo'\n\n// This following example is not touched either way, \n// since it's definitely not an increment.\nconsole.log(strip('foo [1]')); //=> 'foo [1]'\nconsole.log(strip('foo [1]', { removeRawNumbers: true })); //=> 'foo [1]'\n```\n\n## Examples\n\n### Windows path increments\n\nAll of the following would return `foo`\n\n```js\nconsole.log(strip('foo (1)'));  \nconsole.log(strip('foo (2)'));  \nconsole.log(strip('foo (22)')); \n```\n\nAll of the following would return `foo.txt`\n\n```js\nconsole.log(strip('foo (1).txt'));  \nconsole.log(strip('foo (2).txt'));  \nconsole.log(strip('foo (22).txt')); \n```\n\n### MacOS path increments\n\nAll of the following would return `foo`\n\n```js\nconsole.log(strip('foo copy'));\nconsole.log(strip('foo copy 1'));\nconsole.log(strip('foo copy 2'));\nconsole.log(strip('foo copy 21'));\nconsole.log(strip('foo copy 219 copy 219'));\n```\n\nAll of the following would return `foo.txt`\n\n```js\nconsole.log(strip('foo copy.txt'));\nconsole.log(strip('foo copy 1.txt'));\nconsole.log(strip('foo copy 2.txt'));\nconsole.log(strip('foo copy 21.txt'));\nconsole.log(strip('foo copy 219 copy 219.txt'));\n```\n\n## About\n\n<details>\n<summary><strong>Contributing</strong></summary>\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n</details>\n\n<details>\n<summary><strong>Running Tests</strong></summary>\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n</details>\n\n<details>\n<summary><strong>Building docs</strong></summary>\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n</details>\n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on September 04, 2019._","_attachments":{},"homepage":"https://github.com/jonschlinkert/strip-filename-increment","bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT"}