ObsidianToAnki / Obsidian_to_Anki

Script to add flashcards from text/markdown files to Anki
GNU General Public License v3.0
1.54k stars 136 forks source link

(Re-)creating a deck from notes with given IDs seems to fail silently #621

Open daniu54 opened 3 weeks ago

daniu54 commented 3 weeks ago

I have cards with given IDs and I would like to give them to my colleague. Unfortunately, it seems to not be possible to generate an Anki Deck from cards, which have IDs provided already.

This could also be a problem, if one deletes the deck locally and needs to regenerate it. I have tried to clear the Media Cache and the File Hash Cache.

Or is this an intended feature?

daniu54 commented 3 weeks ago

My current solution is to remove all IDs from the cards using the following script:

#!/bin/bash

# Use the current directory as the Obsidian vault directory
VAULT_DIR="$(pwd)"

echo "Removing Obsidian Anki IDs from markdown files at $VAULT_DIR"

# Use 'find' to locate all markdown files in current directory and subdirectories, then process each file
find "$VAULT_DIR" -type f -name "*.md" | while read -r file; do
  # Use 'sed' to delete lines containing the pattern <!--ID: number-->
  sed -i '/<!--ID: [0-9]\+-->/d' "$file"
done

echo "Finished removing IDs from markdown files."