Skip to content

Instantly share code, notes, and snippets.

@timhodson
Last active December 3, 2019 10:20
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 timhodson/8bef7dcf8f9743017ba3cfe190a4db0b to your computer and use it in GitHub Desktop.
Save timhodson/8bef7dcf8f9743017ba3cfe190a4db0b to your computer and use it in GitHub Desktop.
Create directories names for each month of a year
# if using zsh you need to get the strftime function to be available
zmodload zsh/datetime
# We're using bash version 4 range expansion
# to generate number of seconds between the 10th day of each month since unix epoch time `0`
# - we use the 10th day to miss months of unequal length
# - we start from 0 seconds. Every year since 1970 has had the same number of months.
# We then pass those seconds to strftime to build our dirname
# which is then used to create the directory
for seconds in {864000..31556952..2629746}
do
mkdir $(strftime %m-%B $seconds)
done
# add to .~/.profile as an alias
alias monthdirs='for seconds in {864000..31556952..2629746};do mkdir $(strftime %m-%B $seconds); done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment