Last active
December 3, 2019 10:20
-
-
Save timhodson/8bef7dcf8f9743017ba3cfe190a4db0b to your computer and use it in GitHub Desktop.
Create directories names for each month of a year
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
# 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