Automating Image Import based on Tag number

I am currently facing a challenge in automating the import of screenshots into my Anki cards based on their corresponding Question No. I have thousands of cards, each tagged with a unique Question No., and I possess image files with screenshots of these questions.

  1. I have Anki cards tagged with Question numbers.: [example tag: #Boxes::#Red::100-200::178.]
  2. I have image files saved on my computer corresponding to these questions, labeled with the same Question No. (example directory: Users/Belinda/Desktop/image178.png)
  3. I want to create a script or code that can identify the Question No. from the image file and import the relevant screenshot to the back side of the corresponding Anki card with the right tag.

Has anyone attempted a similar automation task within Anki?
Are there existing add-ons or scripts that could be adapted for this purpose?
Could someone provide a sample code snippet or guide on how to achieve this?

I have tried various options including AnkiConnect with Python etc. but am just a bit stuck. I understand this might be a complex task, and any help or direction would be immensely valuable. Thanks.

There is an add-on for importing and exporting templates. It is apparently no longer maintained and does not work anymore with versions 23.10+, but there’s a very simple edit that you can make to one file to fix that. It also won’t work if your card or note names contain characters that are illegal in file names in your operating system (most notably : on Windows).

So you could export your templates using the add-on, and also export your Notes as plain text (with tags), and then cook up some Python script that reads the notes file for the tag information and reads and modifies the templates files (each exported template will be in a separate flat file within a directory tree based on the note name and card name), and then re-import those modified templates with the add-on.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.