Skip to content

Instantly share code, notes, and snippets.

@anandpathak
Created February 25, 2019 12:20
Show Gist options
  • Save anandpathak/6ea25be2f3178c21c2ceca46d4c460f9 to your computer and use it in GitHub Desktop.
Save anandpathak/6ea25be2f3178c21c2ceca46d4c460f9 to your computer and use it in GitHub Desktop.
rename file to hash name
const fs = require('fs');
const cpryto = require('crypto');
const basePath=""
function rename(filename){
var hashName =crypto.createHash('md5').update(filename).digest('hex');
fs.rename(basePath+"/"+filename,basePath+"/"+hashName,(err,res)=>{
if(err){
console.log(err);
}
console.log(res);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment