Obsidian_to_Anki v2.9 - a feature-rich script that allows you to add notes from Obsidian to Anki

Supported:

  • Custom note types
  • Substitutions (see GitHub for explanation)
  • Updating existing cards
  • Tags
  • Adding to different decks
  • Markdown formatting
  • Embedded images (see documentation)
  • Audio (see documentation)
  • Deleting notes from Obsidian
  • Running the script over all files of a directory automatically
  • Inline notes
  • Easy cloze formatting
  • User-defined custom syntax

Feel free to ask me questions about it!
See the Trello for planned features.

20 Likes

Interesting.

If I have a note with information on it, i.e. some YAML data at the top and text in the body, can I amend it as follows to make usable for your script:

---
Author: 
Book: , p. 
Original number: 
Site: 
Transcluded in: 
Note creation date: yyyy-mm-dd
---
Tags: #communication #personality #presence #trust #perception

---

body of text here
<br>

###
<br>
<br>
<br>
<br>

*Footnotes*

And then below *Footnotes* I add:

---
Anki data:
START
{Note Type}
{Note Data}
END

Will the script pickup the Anki data and leave the rest of the note untouched, or will the text above it confuse the script?

I think that should be fine. The way I’ve set it up, the parser for converting Note type + Data -> Anki note only ever ‘sees’ text between START and END. So the text above shouldn’t confuse it.

Do let me know if there are any problems though.

@Pseudonium Yeah, that’s what I thought. I’ll give it a shot.
BTW, does it run through all the notes in the vault?
And if you run it a 2nd time, will anki cards get duplicated?

Thanks for building this so that I didn’t have to, hah!

I wonder if there’s a way to achieve some kind of syncing. E.g., if you update a note in Obsidian, is there a way to make sure the associated Anki card(s) get updated rather than creating new ones…? Hm.

So at the moment it works on a per-file basis. You’d have to go through the files individually.
I’ve set a flag to disallow duplicates (from AnkiConnect), but I haven’t tested it.

1 Like

So there is a part of the AnkiConnect API that allows you to update an existing note rather than create a new note. I haven’t looked into it that much though.

1 Like

So I did some testing, and the current script will not add duplicates. If you run it a second time on the same file, nothing happens.

I’ve just released v0.2, which should allow you to do this!

3 Likes

@ryanjamurphy: there is also this.

1 Like

Great!! Hope you will integrate your script into OB after its api releases;)

1 Like

Yeah hopefully that won’t be too much of a hassle. As long as the API gives me access to the text of the file, I shouldn’t have to make too many modifications.

I’m adding support for markdown formatting in the next release (so you can use bold, italics etc). It might be possible to auto-embed images as well, though I haven’t started working on that.

1 Like

I did not get it to run. I posted the output from my terminal on your Github page.

v0.4 - Markdown formatting and Embedded Images Update is out! Let me know if there are any problems.

@Pseudonium: so if you have amended a card between the START and END, and you then run the script for a 2nd time on the file, it will not pick up those changes. Correct?

@Klaas For v0.2+ it does update automatically, this is only v0.1 behaviour

@Pseudonium: OK, clear. I plan to have a play tomorrow, and will give feedback.

Works great! Thanks!

Also if anyone can’t spare the 10 seconds to make it themself, I made an Alfred Workflow to make clozes as if in Anki:

Cloze-in-obsidian

1 Like

From your Github page:

To add appropriately-formatted notes from a file, run obsidian_to_anki -f {FILENAME}

Surely, just the filename is not enough, the script needs to know which Obs vault to look into. So, does {FILENAME} mean {path/to/vault/FILENAME}?

Yes, that is correct. I’ll amend the documentation to read ‘FILEPATH’ in v1.0