Skip to content

Instantly share code, notes, and snippets.

@cynthiahqy
Created October 13, 2022 08:21
Show Gist options
  • Save cynthiahqy/722be78c3be8e78e979afba3bcc9b446 to your computer and use it in GitHub Desktop.
Save cynthiahqy/722be78c3be8e78e979afba3bcc9b446 to your computer and use it in GitHub Desktop.
script for creating 12 month files for a given year with obsidian YAML
#!/bin/zsh
year=$1
month_names=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
month_num=(01 02 03 04 05 06 07 08 09 10 11 12)
mkdir $year
for (( idx = 1; idx < 12; idx++ )) ; do
file_name=$year/${month_num[idx]}-${month_names[idx]}.md
if [ ! -f $file_name ]; then
touch $file_name
echo "---\naliases: [\"${month_names[idx]} $year\", \"${year}-${month_num[idx]}\"]\n---" > $file_name
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment