Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/usr/bin/env node
  2.  
  3. const fs = require('fs');
  4. const path = require('path');
  5.  
  6. const ids = [];
  7. const dir = path.resolve(__dirname, process.argv[2]);
  8. for (const f of fs.readdirSync(dir)) {
  9. const format = path.resolve(dir, f);
  10. for (const d of fs.readdirSync(format)) {
  11. const day = path.resolve(format, d);
  12. for (const file of fs.readdirSync(day)) {
  13. ids.push(Number(file.slice(file.indexOf('-', 7) + 1, file.indexOf('.', 7))));
  14. }
  15. }
  16. }
  17.  
  18. ids.sort();
  19.  
  20. const sz = ids.length;
  21. const lo = ids[0];
  22. const hi = ids[sz - 1];
  23. const tot = hi - lo;
  24. const pct = sz / tot;
  25.  
  26. console.log({lo, hi, sz, tot, pct});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement