Is there a plugin or a workaround to mark a directory (with a couple of subdirectories and about 100 files) and to add to all files a “footer”. I dont mean to do it with a template and go through all the 100 files. I mean with a click to add something to all files. Is there a workaround for it?
The only plugin I know that might do it is Global Search And Replace. I don’t know if it has a way to replace “end of file”.
You can probably do it with a fancy text editor like Visual Studio Code or BBEdit that can operate across multiple files. It would also be possible with a shell script if you’re into that sort of thing.
Of course, make sure your backups are up to date before changing many files at once.
Actually a template would be the way forward, I think. Using Templater you would have access to javascript which would allow you to loop through the 100 files, and read and modify the content of each file.
For every template and (it follows) every file, I add a comment by itself in the final line:
%%EoF%%
If I ever need to add anything to all the files or to all the files in a given folder, I use the end-of-file marker for search and replace, usually using VS Code. Not pretty and not perfect but this has helped me a lot, especially adding inline metadata or Dataview queries.
I expect there are better ways to do this.
I now also use a similar start-of-file comment at the top of each file or on the first line under a YAML header (if used).
If I’m not mistaken, the sidebar search of VS Code uses RUST regex, and here is a specific reference to empty anchors:
It says that if not in multiline, the anchor $, will match on end of text, aka the end of file. If in multiline, it’ll match on end of line. So there shouldn’t be a need for inserting a dedicated %%EoF%% marker.
Still, if using a plugin like Templater, you’d get the tp.file.content, and anything after that is after the previous end of file. And you wouldn’t then need to use an external tool.
An alternation of this idea to just add a marker is to add something like the following on the first line after the YAML, and on the last line:
This would allow you to change those two specific dv.view() files, and the changes would be seen all across your vault immediately. This way you can update the top and bottom part of your notes any way you feel, whilst keeping the notes to the point on whatever topic they’re about.
I use a setup like this for my daily notes, making it easy to change whenever I feel like it or think of something neat to put into the header/footer sections of my daily notes.
Awesome thank for the many replies. Unfortunately I am not into coding. Is there any Tutorial with javascript who already did this kind of stuff? Thank you very much