Skip to content

Instantly share code, notes, and snippets.

@coolicer
Last active April 8, 2018 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolicer/c02125d3437dd2b6642ac1f3a737a528 to your computer and use it in GitHub Desktop.
Save coolicer/c02125d3437dd2b6642ac1f3a737a528 to your computer and use it in GitHub Desktop.
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