Created
December 14, 2010 13:36
-
-
Save tyage/740420 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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