Track File Change Dates on Obsidian

Photo of author

I have recently started building a Digital Garden on Obsidian. I like the analogy of ideas being equal to seeds and then tending them until they grow into something bigger: 🌱 -> 🌿 -> 🌳

To imitate the growth phases automatically, I need to track when a file was created and how many times it has been edited.

I found a plugin on Obsidian (Update Time on Edit) that keeps track of the created date and modified date as a frontmatter. It however only keeps track of the last modified time.

I found another plugin that allows you to generate frontmatter for a file using Javascript: Obsidian Frontmatter Generator. I was able to tweak it to track file change dates.

So here is how I used the plugin to keep track of every edit I make to each file.

{
    edits: (() => {
        // Fetch list of edit dates. If not set yet, use empty array.
        currentEdits = file.properties?.edits || []

        // Clone the existing edit list into a new array. The plugin
        // can't detect changes made to existing list.
        result = [...currentEdits]

        // Fetch today's date and get rid of timestamp
        // I am only intersted in the date, not time.
        today = new Date().toDateString()

        // Insert the date in edit list if it's absent
        length = currentEdits.length
        if (length == 0 || currentEdits[length - 1] != today) {
            result.push(today)
        }
        return result
    })(),
}

And that’s it. Any time you edit the file, the date should be appended to the frontmatter if it’s not on the list.

I track the file growth in my Digital Garden using this method. You can use it however you want.

Maybe I will try to wrap it up into a plugin as a pointless project?

🗞️ Don’t miss the latest posts!

Subscribe to the Weekly Newsletter

I won't spam. Promise!

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments