What I’m trying to do
I play a board game called go/igo/baduk/weiqi (depending on what Asian country you hail from). Best practice is to review your own games regularly (if not every game you play), so I’ve started writing down my thoughts on each game in an Obsidian note with headings like “Overall thoughts”, “Biggest blunders”, etc.
Game records from online servers are invariably stored in an extremely concise ASCII text format called SGF (see Smart_Game_Format on Wikipedia). The files themselves are more than small enough to store in my vault, and there is even the Cgoban SGF community extension to display the files in a visually meaningful way.
I’m currently copying the sgf files into my vault, and using templater to create notes in my “go-reviews” folder. Templater creates the blank frontmatter and section headings, but I’m currently filling everything out manually after opening the sgf file in an sgf editor to extract the metadata.
But I want to automatically create a markdown note from sgf files. I’d like to automatically extract the metadata from the sgf file to create the frontmatter in the markdown, as well as a link to the unadulterated sgf file in the body of the not (so that I can load/view/potentially-alter the file in an sgf editor external to Obsidian). Every sgf file includes information like the date of the game, the player names/ranks, the software that created the file, etc. I’d like all or most of this info in the frontmatter for the markdown note.
Things I have tried
I’m fairly certain I’ll figure this out on my own eventually, but I’m down with a cold at the moment and I’m hoping for enough spoon feeding to make the project a little easier.
I’m fairly certain I can use tp.file.content() and some Javascript to extract the metadata I need for the markdown template (e.g. `RegExp(“PB\[.*\]”) to extract the black player’s name) , but I’m struggling to figure out the easiest possible workflow to actually create the markdown file while also leaving the source sgf file untouched.
I’d like to just drag files from Finder on my mac into a folder in my vault, and have that action trigger the creation of a related markdown note that I can subsequently edit. I don’t particularly care about the folder hierarchy. It doesn’t matter to me if the sgf and review folders are siblings or hierarchal.
I’d like the sgf filenames to be unchanged from whatever I download from a server (each server has their own naming conventions), but I’d like my markdown note filenames to always be have filenames in the format <DatePlayed>-<BlackPlayerName>-<WhitePlayerName>-<Result>.sgf where all fields are extracted from the metadata in the sgf file.
Any and all help will be greatly appreciated. I’m just looking for enough pseudo-code to get going.
Thanks in advance!