Skip to content

Instantly share code, notes, and snippets.

@cacheflow
Created April 5, 2017 01:32
Show Gist options
  • Save cacheflow/eb59695d25ac2943e2f81cc865b81380 to your computer and use it in GitHub Desktop.
Save cacheflow/eb59695d25ac2943e2f81cc865b81380 to your computer and use it in GitHub Desktop.
var fs = require('fs')
var path = require('path');
var imagePath = path.resolve(process.cwd(), 'assets/images')
console.log("starting script")
fs.readdir(imagePath, ((err, files) => {
files.filter(file => file.includes('@')).forEach((file) => {
var fileSplit = file.split('@')
var newImagePath = path.resolve(imagePath, fileSplit[0] + '.png')
var oldImagepath = path.resolve(imagePath, file)
fs.rename(oldImagepath, newImagePath, (err) => {
if(err) {
console.log(err)
}
})
})
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment