An Almost Anonymous Blog

Following up on Automating Obsidian

As I alluded to in my thoughts yesterday, I am overthinking my Obsidian automation. That's not a problem, it's a fact. I don't mind overthinking if it is productive, and in this case I think it is.

I wrote in detail about how I'm automating my weekly note review on Tuesday; that's working like a charm now that the bugs have been worked out. This morning though, I was looking at the daily note that Obsidian's plug-in creates for me. I like including the ISO Week number as well as the written date. So today's daily note has a title / filename of 16 Thursday April 17 2025.md. That's great except on a quick glance I keep thinking it's saying it's the 16th. It doesn't look right.

I would like it to be something like Week 16 Thursday April 17 2025.md or even Thursday April 17 2025 Week 16.md. I suppose I don't need to include the week number in there - that's mostly relevant for the weekly review. At the same time, it helps to make sure when I look at the source for the weekly review note, I can quickly verify that yes, all the week numbers match up.

Unfortunately, Obsidian's daily note plug-in is limited when it comes to creating filenames based on dates. I could set the title in the template to include word strings, but that's YAML information, not the filename. What I'm thinking instead is creating a shell script that will do that for me. I already have the basics of what I need to do set up in the script that appends my weekly review file - I can take that and apply it to a new script. Here's what I'm thinking (I haven't written the script yet or uploaded it to my server, at this point we're at the theoretical level).

#!/bin/sh

# Get ISO week number
WEEK_NUM=$(date +%V)

# Get full date parts
DAY_NAME=$(date +%A)
MONTH_NAME=$(date +%B)
DAY_NUM=$(date +%e | sed 's/ //g')
YEAR=$(date +%Y)

# Build daily filename
DAILY_FILENAME="${DAY_NAME} ${MONTH_NAME} ${DAY_NUM} ${YEAR} Week ${WEEK_NUM}.md"

In theory this should mean DAILY_FILENAME would result in Thursday April 17 2025 Week 16.md. I figure the next step of the script would be to check if the file exists; if it does, do nothing. If not, then create it and add the template information.

# Construct File Path
FILE_PATH="/mnt/Obsidian/Infosphere/Daily Notes/${DAILY_FILENAME}"

# Create file if it doesn't exist 
if [ ! -f "$FILE_PATH" ]; then
  {
    echo "---" 
    echo "title: Daily Notes ${DAY_NAME} ${MONTH_NAME} ${DAY_NUM} ${YEAR}"
    echo "tags:"
    echo "  - notes" 
    echo "  - Weeknotes" 
    echo "---"
    echo ""
    echo ""
    echo "### Links" 
    echo "- asdf"
    echo ""
  } > "$FILE_PATH"
fi

I think this should work. I would 100% test it with a throwaway .md file first, before setting up a daily automation. But from there, I think I would run the append script at the same time. In that case, the script would look like this:

#!/bin/sh

# Get ISO week number
WEEK_NUM=$(date +%V)

# Get full date parts
DAY_NAME=$(date +%A)
MONTH_NAME=$(date +%B)
DAY_NUM=$(date +%e | sed 's/ //g')
YEAR=$(date +%Y)

# Build daily filename
DAILY_FILENAME="${DAY_NAME} ${MONTH_NAME} ${DAY_NUM} ${YEAR} Week ${WEEK_NUM}.md"

# Construct File Path
FILE_PATH="/mnt/Obsidian/Infosphere/Daily Notes/${DAILY_FILENAME}"

# Create file if it doesn't exist 
if [ ! -f "$FILE_PATH" ]; then
  {
    echo "---" 
    echo "title: Daily Notes for ${DAY_NAME} ${MONTH_NAME} ${DAY_NUM}, ${YEAR}"
    echo "tags:"
    echo "  - notes" 
    echo "  - Weeknotes" 
    echo "---"
    echo ""
    echo ""
    echo "### Links" 
    echo "- asdf"
    echo ""
  } > "$FILE_PATH"
  doas /mnt/Scripts/append_daily_to_review.sh
fi

I think I'm going to give this a try this afternoon, once all my busywork is done. I probably won't update this post but I'll throw something in my Weeknotes either way.

Reply by email   Share this post

Or if you prefer, find me on Mastodon. And there's also Bluesky!

#process #project