-
-
Save tjwebb/7d228cde250c5befb6ee6e5d6434a174 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
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