Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Count lines by file extension and path and output csv ready to be sql-analyzed
/* eslint-env node */
const fs = require(`fs`);
const path = require(`path`);
const filePaths = fs.readFileSync(`${__dirname}/file_list.txt`, `utf-8`).trim().split(`\n`);
console.log(`Total files`, filePaths.length);
for (let i = 0, len = filePaths.length; i < len; ++i) {
const filePath = filePaths[i];
let lines = null;
try {
lines = fs.readFileSync(filePath, `utf-8`).split(`\n`).filter(l => /\w/.test(l));
} catch (e) {}
if (lines) {
console.log(`${filePath}, ${path.extname(filePath)}, ${lines.length}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.