and this script in the scripts folder of my Obsidian vault:
In theory… this should work.
If I app.vault.read the file after I app.vault.modify it to remove the tabs… I can see that the tabs are removed (see bottom left part of each console.log).
(Note: I don’t think the TypeError from Meta Edit is relevant here.)
Yet, when I look at the file after templater has ran (and I know it has because the templater code is gone from the note), I see that the tabs are still there:
re: await before file modification, that makes sense. Will try that. I haven’t seen many examples use await - I wonder why they don’t? Anyway, here’s a rerun with await and using replaceAll(". ", "") as I had before:
re: error result. There are none related to this specifically, that I can tell. The TypeError after the console.log I believe is from Meta Edit and is unrelated.
Does that mean you’re running the script from within the file itself?
If that’s the case, that could be your issue as well. Then that would need to be kept in memory, whilst you then reread and change the file. If nothing else that does sound like you’ve got some unhealthy race conditions going on.
A few hours back I prepared a script to change the frontmatter of multiple files, and I’m wondering whether something similar could be used in your case. But I would never run that (or similar) script from within the note itself. To me that sounds like sawing off the branch you’re sitting on.