44 minutes ago · Tech · hide · 0 comments

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 +=…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.