Automatically Organizing My Markdown Notes By Date 0 ▲ Vinit Kumar 111 days ago · Tech · hide · Fediverse post I love writing in Markdown because it is simple. I don’t need to open a particular application, choose a template, or think about formatting. I can create a file in my home directory and start writing immediately. The problem comes later. After a few days, the home directory fills up with random Markdown files. The writing is easy, but tracking when I wrote something becomes unnecessarily difficult. I wanted to keep the easy part while automatically organizing every file inside notes/YYYY-MM-DD, based on its creation date. This is the script I use: #!/bin/zsh set -eu setopt NULL_GLOB source="$HOME" notes="$HOME/notes" for file in "$source"/*(DN.); do extension="${file:e:l}" [[ "$extension" == md || "$extension" == markdown ]] || continue day=$(stat -f '%SB' -t '%Y-%m-%d' "$file") directory="$notes/$day" mkdir -p "$directory" name="${file:t}" destination="$directory/$name" sequence=2 while [[ -e "$destination" ]]; do destination="$directory/${name:r}-$sequence.${name:e}" (( sequence +=… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town