On renaming files, headings and blocks, update source and linked files' date modified timestamp

I’ve been fooling around trying to have a patch made in Javascript Init plugin leveraging vault rename and modify even listeners, but there has always been something that made a mess. AI help goes only so far…

Use case:
Many people have date modified time stamps in their properties, possibly using @AlanG’s Frontmatter Modified Date plugin or otherwise.
Then people would probably use DataView queries to use these last modified dates. People will also publish their material maybe based on these queries.

The problem comes, when you rename a file or a heading (you will be less likely to rename a block, but it also can happen), then the linked files’ content changed, but the content change will not be reflected on your custom date modified timestamp.

Workaround:
Using mtime for Dataview queries. Obsidian does the renames, updates the links and when saving the files, mtime values will be updated.

Problem with this:
But then if you go to a different platform, mtime will be different for each file, based on file created on that operating system (syncing your files will create a unique stamp for your files).

@mnaoumov I see you have a couple utilities leveraging these listeners; I wonder how difficult it would be to twist some of the existing code to meet these requirements…?

I guess updating the source file’s date modified stamp would be just as welcome.
The plugin would of course need the setting to allow people to specify what frontmatter key they are using for date modified.

1 Like

You can handle on('modify') - Developer Documentation

And update your timestamps accordingly

Well, I know from experience I cannot handle…
When I thought I had it working, and updated the files with processFrontmatter, in a while I saw that other files that were not linked also got updated exponentially. And truth must be said that I am a better prompter than coder…

I am thinking that Dynamic Views – when ready – might bring some sort of solution to this in the future, but that can be months from now.

In order to figure this out, you need to add some logging into the code that modifies the files to identify why it was triggered. As you are saying it modifies the not linked files, it would be useful to understand why it was triggered at first place

Mikhael, even if I got lucky and would manage to put together something, I still wouldn’t put it up on the forum in good conscience. This problem obviously is shared by many users out there. I can do another 1-2 workarounds (to do with git timestamps or use a python script to update my own links manually, at a push), but again, not ideal for Sync users etc.

1 Like