{"_id":"strip-filename-increment","_rev":"4-904d14ccb9d20dfebf87f4b35a1fc7f7","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"},"versions":{"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":{"integrity":"sha512-dZ6RrIJbEL7uuen1ewW7JRufGxm/P50pD0blgd4AHFCD/P10ajaXAIz8HDre5EtNkSlnifUiMOJ5jsnYr85/7w==","shasum":"0a774eef947b4242cf3dff46e63f03ff55921a29","tarball":"https://registry.npmjs.org/strip-filename-increment/-/strip-filename-increment-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCtgLhMs61BbasxqSSuENPGtNcR5FBOruDuLQI7BgOiUgIhAL9foDOg3W5VM2Av7RF1j5Ai06EjiifIWhcsxzkkKdtb"}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment-0.1.0.tgz_1498976941414_0.707336179446429"},"directories":{}},"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":{"integrity":"sha512-+HLnalq+J6Q5tkwY3wQpLR+VcPJ9Mkge9hTIMAZ6DG+B1p2n7P4uZA2FRQJ9XWnlqauySykBg5qRwpXncHT3vQ==","shasum":"3e33c3cfce28cfda639c421745087facf6194f7a","tarball":"https://registry.npmjs.org/strip-filename-increment/-/strip-filename-increment-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZGddjLKIca9e25A+OUUb5GSG6dAl/Lucld0nZAvre6wIhAKYkL0q1KkMM5Q2ONId9R3RAXvE3xgrLfdWjgCpIwyuY"}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strip-filename-increment-1.0.0.tgz_1499750896975_0.5705821004230529"},"directories":{}},"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":{"integrity":"sha512-rZXOdN13ePDgFX8FRgRKoSv+ngKClzLNRftpkFc6I+Aat7Wad5EZ8D8gbzS4cQQs70yYNQkN85rJlKeHinS0SA==","shasum":"0f196db60ccfbe9b6dbfea9b7c2c39c1004f570f","tarball":"https://registry.npmjs.org/strip-filename-increment/-/strip-filename-increment-2.0.0.tgz","fileCount":4,"unpackedSize":13305,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdb0WpCRA9TVsSAnZWagAA8Z4P/24pl27+buvFp527bZ3P\naTyDDr9qGAbGhGcpvp4nH1wHwRpRae/bg/KoZkiBV4cDNZD4aCFDirAlxerH\nIKRITRdZdZ9nYtIXu2ZlImK3efVioqhmkF1tahAlxHZYRqXBQDjq4sGpuBuw\nA71T42Lxmv15ajL7uMGOzylXMedmSm1gU6eWYSnXFPozJoBXJMPbg8LnLI4e\n9P3fVE041uvt8MmU7DthjGW/9B8krZ67g05WDqF9QHgDcit7KHBKgFwGVTRV\ntyYPjICRURAClB1G4ENdTnF1F7rhjeuoAkwd4iDdmfK041MvjgnxUVogsX+o\nsrj5O4DLwHt31E6WBMy9mMaN/NOyTn/vj2vPCPTdHkDH5aDKlqNtOh52iZyS\nTEzV9MBW/g4Pahf9kGGRtAEttSRT0FC45l9Nn95pwD3VCQOcczopN7PKQJK3\nGbewZi5E5q0MCQaieVoNgxLsrvUqjGhlPaUD7Cbua0ye3/24WUf5vAGUdC1j\nPkiNHKh19+bNFwXLYToRt3N6/AkSbJWObvJ+NI7BNstDuJYoqDOCDNhkQDQK\ndW0N+uC7qLtxZdtlfv09gw/meWVd0FYLCH0GEtxojDeza0vXD9r3CEgAtC7s\n7zYor42lS2q5pIJIC3t7DfiT7weT0Yg25dO8Y9UVIUpcNDQSNwXqgRtmFVpL\nGPnP\r\n=Ptif\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCh1xRTTGnoa0x9r2f2JDqK3+aeHN1RE9meIU1tiX2dgAIgRrviJBM9sIr91qeLuDbkGcU4saAxDXSjQJ+gKVYRSS0="}]},"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},"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":{"integrity":"sha512-+v5xsiTTsdYqkPj7qz1zlngIsjZedhHDi3xp/9bMurV8kXe9DAr732gNVqtt4X8sI3hOqS3nlFfps5gyVcux6w==","shasum":"3feca2ebd529d4cdcad0281a9bbb2660b096fcc6","tarball":"https://registry.npmjs.org/strip-filename-increment/-/strip-filename-increment-2.0.1.tgz","fileCount":4,"unpackedSize":18069,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdb00JCRA9TVsSAnZWagAA5+4P/jlwTWi7GTkQPMZmH5ze\nWmTgD0pMXdED05sSCl9nk/NwDiRRfVXGxZ+UC0dh+CeKNO9qnMVJeU0ZBB8i\nVtKV/qvUIqar3EMHucSoIJu9rx03NoHGsV4uCtXcKS7SyCMGaZofmY8W1qCS\nQN5tJPEcjeCYzGyQUbTev28m+4Bu4nqCN70YKbFftueMFQuqJ8YiUXUz2dsw\nOltsE+ywqdGzzoJ5YVR15qoBg0BncGLshUOWigeXaRH5W+CTDEYa2xuE3ncH\nSWvd7qEDeQ17491kO2xIZ1JL0XipUUg1aRGuvcqe3c/RlpEkUkzN62PPxeIV\njrLqlYJgUKoVOKZeFf5lDee/7IsDWFHPAtWzdzXNh+acGNk2RQlid0xKlK3O\nkTUja7fQc/jCIlzuge1kPsZUY9krqimFCtndmYvz/k4Q7WLyNO0q2BhqZ6AZ\n1wt1mWgG/0UZjWTlwPb7ZUTHHOAqq/VPNbTlXxzdCBs7LyOKT93OimADfefu\nZLPd7ItAomCy8MpOOghP61kdb/Tec1jeeEQaVhzkaXPQDBtSDAk6aYnwaSQ1\n/hzWaPA2n9/b9P9LZc9EdCDGCgVxBDtYBNPicTnzS9BMZ7TgDANMdK5bPuVh\n1LhSHmsdcs+A8VU/zpDUD9wlcDYhDNN+nyJdjczcZWWwm86MRRGo9aXXQHJO\nb/+J\r\n=4ahC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDBc5zonmqjXQdRK7UtUjyfqWID1WhsTlMjiO8VQpY9ywIhAOWGmCKoyRUCb/fj9+CiZ3jwSutR/lUe1BcFPBD8WepY"}]},"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}},"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._","maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2022-05-18T21:11:00.963Z","created":"2017-07-02T06:29:02.413Z","0.1.0":"2017-07-02T06:29:02.413Z","1.0.0":"2017-07-11T05:28:17.923Z","2.0.0":"2019-09-04T05:03:36.765Z","2.0.1":"2019-09-04T05:35:05.330Z"},"homepage":"https://github.com/jonschlinkert/strip-filename-increment","keywords":["filename","increment","strip"],"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/strip-filename-increment.git"},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"bugs":{"url":"https://github.com/jonschlinkert/strip-filename-increment/issues"},"license":"MIT","readmeFilename":"README.md"}