Syncing collection deletes all images

When I try to sync my images and audio it keeps all the audio just fine but deletes every image. Probably because it doesnt recognize that I am using the images.

My image field is filled like this:
(Show name, episode, timestamp.jpg)

The formatting looks like this:

<img src="{{Snapshot}}"

I have over 120k cards so what do I have to find and replace to update all the cards so they don’t delete on sync?

Media references to fields are not supported.

There is a Find and Replace feature in the browser, but I don’t think it can handle your case.

I think the Find and Replace Tags using Regular Expressions add-on is the answer. I didn’t test this but you can search for the pattern (.*) and use <img src="\1"> as the replacement string.

As always, back up your collection before messing with things!
Also don’t forget to change the <img src="{{Snapshot}}" block in your template to {{Snapshot}} after using find and replace.

Maybe @Rumo can further help with this.


I think this a misunderstanding. The add-on is for replacing Anki tags, not HTML tags. :slight_smile:
I build it because Anki doesn’t support regex replacing in this case. But since the problem here is with the content of fields, you can just use Anki’s built-in feature to follow @abdo’s instructions.
For recent Anki versions, the back reference syntax is ${1}, though, as you can read here.
If you have image references in a lot of different fields and/or other content in the same fields as well, you will need to use a more complex regex to match the image file names and replace only them.


Oops, I didn’t actually pay much attention to the “Tags” part of the add-on name :sweat_smile:
I remember that the regex crate supports this but used the wrong syntax and was confused why it’s not working.


Rumo: Regarding the description on that add-on - you’re probably already aware of this at this point, but you can reference match groups in the replacement string. What Rust’s regex crate does not allow is referencing a group from within the search string, due to the performance issues it can cause.

Anki’s tag replacement code supports a regex option, but it is not yet exposed by the UI.


You’re exactly right. I noticed my mistake afterwards but didn’t get to updating the description since there doesn’t seem to be much demand for this functionality anyway. :sweat_smile: