75lb / renamer

Rename files in bulk.
MIT License
529 stars 30 forks source link

Can't able use it as global node package #46

Closed kathirr007 closed 4 years ago

kathirr007 commented 4 years ago

Hi,

First of all Thanks for this awesome package.

It works well with local node_modules in renaming multiple files with a JavaScript file for renaming.

But i wanted to rename files without installing package locally, but in global installation with npm i global renamer this installed renamer globally, but when run the renaming script in any folder which doesn't have renamer package installed locally is not working.

here is the script i am using to rename files.

/* eslint-disable */
const Renamer = require('renamer')
const renamer = new Renamer()

renamer.on('replace-result', replaceResult => {
  console.log(replaceResult)
})

renamer.rename({
  // files: [ '0*!(node_modules|code|temp)/**' ],
  files: ['**/*.m4v'],
  find: /(.*)(-\d+)/,
  replace: `$1`,
  dryRun: false
})

Please let me know if this can used as global npm package or not.

Note: I am using the above script as saved in a js file and run using node ./rename.js

Thanks in advance.

75lb commented 4 years ago

Hi.. If you install the package globally, you can only use it as a command, e.g.

$ npm install -g renamer
$ renamer --help

If you want to use the package programmatically (from a Nodejs script), you must install the package locally, e.g.

$ npm install renamer
$ node ./rename.js