rename files with pattern like String.replace(pattern, replace)
$ npm install --save rename-files-b
/
└── foo
├── 1.png
├── 2.png
├── 3.jpg
├── 4.jpg
└── 5.png
//example.js
const renameFiles = require('rename-files-b');
renameFiles('(\\w+).(png|jpg)', '$1_001.$2', {path: '/foo'}).then(result => {
if (result) {
console.log('rename successs');
}
});
//will change to
/
└── foo
├── 1_001.png
├── 2_001.png
├── 3_001.jpg
├── 4_001.jpg
└── 5_001.png
Return a Promise
for true or false.
return true or false
Type: string
|| RegExp
what you want replace
Type: string
what you want replace to
Type: object
Type: string
the path has lots files
- rename-files-cli - CLI for this module
MIT @billyct