Skip to content

rename files with pattern like String.replace(pattern, replace)

Notifications You must be signed in to change notification settings

billyct/rename-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rename-files

Build Status

rename files with pattern like String.replace(pattern, replace)

install

$ npm install --save rename-files-b

usage

/
└── 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

API

renameFiles(pattern, replace, [options])

Return a Promise for true or false.

renameFiles.sync(pattern, replace, [options])

return true or false

pattern

Type: string || RegExp what you want replace

replace

Type: string what you want replace to

options

Type: object

path

Type: string the path has lots files

Related

LICENSE

MIT @billyct

About

rename files with pattern like String.replace(pattern, replace)

Resources

Stars

Watchers

Forks

Packages

No packages published