Skip to content

Instantly share code, notes, and snippets.

@tjwebb
Last active February 21, 2017 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjwebb/7d228cde250c5befb6ee6e5d6434a174 to your computer and use it in GitHub Desktop.
Save tjwebb/7d228cde250c5befb6ee6e5d6434a174 to your computer and use it in GitHub Desktop.
const co = require('co')
const fs = require('mz/fs')
const path = require('path')
function fixStuff (dir, fullpath = __dirname) {
return co(function *() {
const files = yield fs.readdir(path.resolve(fullpath, dir))
yield files.map(f => {
if (yield fs.stat(f).isDirectory()) {
return fixStuff(f, fullpath)
}
else {
if (/\.csv$/.test(f)) {
yield fs.rename(f, f.replace(/\.csv$/, '.txt'))
}
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment