Skip to content

Instantly share code, notes, and snippets.

@coolicer coolicer/rename.js
Last active Apr 8, 2018

What would you like to do?
rename file
const fs = require('fs'), path = require('path')
fs.readdirSync('./').filter(item => item.indexOf('.png') > 0)
.forEach((item, index) => {
let newItem = item.replace(/\.\w+\./, '.')
fs.renameSync(path.join(__dirname, item), path.join(__dirname, newItem))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.