Last active
August 29, 2015 14:15
-
-
Save samuelmaddock/2bcf3a7a710ed7642575 to your computer and use it in GitHub Desktop.
Renames files using `#U[\w\d]{4}` names to their actual unicode character.
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
var fs = require('fs'); | |
var files = fs.readdirSync('.'); | |
var UNICODE_PATTERN = /#U([\d\w]{4})/gi; | |
for (var i = 0; i < files.length; i++) { | |
var filename = files[i]; | |
if (!UNICODE_PATTERN.test(filename)) { continue; } | |
var fixedFilename = filename.replace(UNICODE_PATTERN, function (match, grp) { | |
var codePoint = parseInt(grp, 16); | |
return String.fromCharCode(codePoint); | |
}); | |
console.log(filename); | |
console.log("=>", fixedFilename); | |
fs.renameSync(filename, fixedFilename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment