Skip to content

Instantly share code, notes, and snippets.

@tyage
Created December 14, 2010 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tyage/740420 to your computer and use it in GitHub Desktop.
Save tyage/740420 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
fs = require('fs');
(function (dir) {
var search = arguments.callee;
fs.readdir(dir, function (err, files) {
if (files === undefined) return false;
files.forEach(function (file) {
var path = dir+'/'+file;
fs.stat(path, function(err, stats){
if (err) {
sys.print('Error:'+err+'\n');
} else if (stats.isFile()) {
var newPath = dir+'/'+path.split('/').join('-')+'.txt';
sys.print(path+'→'+newPath+'\n');
fs.rename(path, newPath);
} else {
search(path);
}
});
});
});
})('box2d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment