Automatically update last modified date in note

No opinion - it is certain what is happening, it’s even documented in my code.

  1. Obsidian has an event that fires when you update a file: app.vault.on('modify')
  2. Obsidian has a method to update a frontmatter field: app.fileManager.processFrontMatter()
  3. When you update the frontmatter through Obsidian’s provided method while also typing, it causes an edit on the file which pops up the message “<File> has been modified externally, merging changes automatically.”

The changes I have just made are nothing to do with the above. The changes I made were for you to deal with your external modification of files - e.g. Notepadqq with Obsidian left open, or iCloud.

That’s what I feared, Alan. The advantages of installing either of the two plugins far outweigh the disadvantages (data loss) ATM. Sorry.

I’m confused, why would there be any data loss? In fact I would go so far to say it’s impossible, since I’m using Obsidian’s built-in methods to update the frontmatter. If there’s any data loss it could only be due to an error in their own function, which seems very unlikely.

At the time of the message flashing up, people including me reported characters, lines missing. I linked the full thread.

It happened with the other modified date updater too, Alan.

The other modified date updater (and my plugin previously) used Obsidian’s “file modified” event to trigger updating the frontmatter. This event would be triggered by iCloud (apparently).

The new update mode does not use that event and will not be triggered by iCloud, only by you typing a keystroke.

Yeah but people reporting issues did not use iCloud. I use git too.

Also, how about this I wrote up a few days back?

I updated and reenabled the plugin and will be testing it.

Please let me know how it goes. It will solve the problem of stopping external processes from updating the frontmatter. It has no impact on any issues with Obsidian’s own file merging (in that the plugin does things the “correct” Obsidian way, so it can’t be updated to be more correct).

Those issues are a question for the Obsidian devs, and well outside the scope of this plugin.

As a non-coder, I still understand…that something gets entangled in what needs to be weeded out in core code. I thought first it was about the every-two-second auto-save. Some parts of these processes get tangled up…but as I said, I am no coder.

As I am in the process of publishing important material online (challenging High Academia), I cannot lose face because of textual failures of any kind. I do etymology so every letter must be in place.

I expect 10-50 of my notes to be faulty at this point (not because of your plugin, of course).

The way my plugin works is that it waits until 10 seconds after all typing has stopped before it updates the frontmatter. This reduces the chances of any merge error message.

I did it this way purely because those error popups annoy me, rather than attempting to solve a merge issue.

Another solution for the issue you’re experiencing is to increase that timeout. For example if you set it to be 2 minutes after the last typing occurred before updating the frontmatter, it seems very likely that there won’t be any merge conflict.

See how the v1.1.0 update goes, and if still no luck we can add a configurable timeout length.

  • Yeah, I’ve seen it. I just typed one character and some time passed before the date changed.
  • That’s not good, because many times the editing is done in less than a minute. I edit my notes on an on-demand basis, because the format is reference book style: one note, one topic/lexical term. New data comes in, I do my editing and close the note.

Also, my experience: happened on Win and Linux installs but far less frequently (almost never) on iPadOS. Is it possibly an Electron issue?

It doesn’t matter if you close the note. If Obsidian is still open it will update the frontmatter perfectly. The update happens in the background, you can close the note and move onto something else without any issues.

1 Like

@AlanG So far so good (no idea what you’ve done, I am not seeing the error popups).

But now with the new setting, if I make non-typed changes (e.g. use a command that replaces text), the date field is not updated, of course.

  • Not writing this for you to drop everything now. Just saying.
1 Like

@AlanG could you please let me know how to make it work? What should I add in property field to display file modification date?

@eDEK you don’t need to add anything - just install the plugin (and optionally exclude some folders in the Settings).

Everything happens automatically whenever you modify a note - you’ll see the field appear a few seconds after you stop typing in a note.

@AlanG, I upgraded the plugin to v 1.3.0 and added to a note the new property append_modified_update yesterday.
Today I made some edit, however nothing appears. Where should I find the changes history?

I also note that in my data.json the appendMaximumFrequency property does not exist.

  "frontmatterProperty": "modifiedDateTime",
  "momentFormat": "YYYY-MM-DD HH:mm",
  "excludedFolders": [],
  "useKeyupEvents": false,
  "onlyUpdateExisting": false,
  "timeout": 10,
  "excludeField": "exclude_modified_update"

Can you try changing any setting in the plugin (you can change it then change it back) and restart Obsidian?

It might be that upgrading doesn’t add the appendMaximumFrequency field due to an issue in the code.

Now the json is OK .
Now I would like to test, but I should wait for one day?
What could I put inside appendMaximumFrequency instead of “day” in order to have more frequent updates so that I can understand?
Until now any edit action only changes the modifiedDate field and does not add any history (this should be normal because I only have today edits).

You can use any MomentJS unit of time, e.g. second, minute, hour, month etc.

OK It’s working. I understand that I need to switch to source mode to see the history list.

1 Like