Skip to content

Instantly share code, notes, and snippets.

@aguestuser
Created December 2, 2015 21:58
Show Gist options
  • Save aguestuser/81974f9b7bde96b08fc9 to your computer and use it in GitHub Desktop.
Save aguestuser/81974f9b7bde96b08fc9 to your computer and use it in GitHub Desktop.
import _ from 'lodash';
import fs from 'fs';
/**
* FILENAME: `makeFolders.js`
* USAGE: `babel-node makeFolders <rootFolder> <startMonth> <endMonth>`
*/
const pad = (num) => num < 10 ? `0${num}` : num;
const has30 = (month) => _.contains([4, 6, 9, 11], month);
const [root, start, end] = _.slice(process.argv, 2, 5);
fs.mkdirSync(root);
_.range(start, parseInt(end) + 1).forEach(month => {
fs.mkdirSync(`${root}/${pad(month)}`);
_.range(1, has30(month) ? 31 : 32).forEach(day => {
fs.mkdirSync(`${root}/${pad(month)}/${pad(day)}`);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment