Automate editing Obsidian MD files

I currently have a process for clipping some Reddit posts and storing them in Obsidian. In addition, I have a DataView page that allows me to process through them—fixing formatting and other changes like that. Finally, I want to send the Obsidian file to shortcuts to perform some repetitive editing tasks (i.e., Changing metaData, Automatically formatting title lines. Is there a good way to do this on an iPad and a Mac without shortcuts (maybe templater, but I don’t know how to run scripts with templater?

Lastly, how is there not an Obsidian Categorie or tag on here lol?

1 Like

You might want to ask directly on the Obsidian forum.

In the meantime, which parts are you hoping to automate (without Shortcuts)?

I want to automate editing some metadata. I have a processed: No that I need to switch to Yes. I want to be able to highlight some text and add it as a line in Links:. Mostly I am wanted to learn more about scripting to automate text edit and looking for some examples to begin.

So what I have found is this snippet by pbhopeful on the obsidian forum

<%* 
  var file = app.workspace.getActiveFile()
  var t = await app.vault.read(file)
  var s = t.replace("processed: no", "processed: yes").replace("{The Griffon's Saddlebag}","{TGS}")
  app.vault.modify(file, s) 
%>

This is a great starting point and allows me to automate with templater to be fully cross-platform. I am very new to programming with JS and TS is there good documentation on using the app or workspace methods. I would like to use this to do some more robust editing (I.e., changing note titles, adding text to the end of the first p1 on a doc…)

1 Like

The only docs I have seen are on Github, but it is more a set of definitions than what you might traditionally expect as documentation.

The usual advice seems to be if you have API/plugin questions to post in the Obsidian Discord (and not in the Obsidian Discourse).

1 Like

That’s true, if only because folks tend to be a bit faster on the Discord.

Note that there is a specific thread dedicated to Templater in the plugins-advanced channel.

Templater itself also has a great showcase of useful templates on the plugin’s GitHub repository: