Created
February 25, 2019 12:20
-
-
Save anandpathak/6ea25be2f3178c21c2ceca46d4c460f9 to your computer and use it in GitHub Desktop.
rename file to hash name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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