Replace links to audio files like <a href > with [sound:]

Is there a way to batch transfer <a href> into [sound:]?

Basically, I have a lot of audio files that are embedded in the html and all of them are in the format of <a href="XXXXXX.mp3">, and I 'd like to change these into [sound:XXXXX.mp3] since I found out the former would interrupt music playing on iOS.

Thx in advance!

Use Find and replace:

https://docs.ankiweb.net/browsing.html#find-and-replace

Select the notes, search for <a href="and replace it with [sound: then search for mp3"> and replace it with mp3]. (Make sure, there are no other links starting with <a href=").

You can also do this in one step, if you use regular expressions (Regular expression - Wikipedia) with the regular expression option enabled in the dialogue.

It should be something like

Search (<a href=")(\w*.mp3)(">)
Replace [sound:$2]

It searches for your current link, saves the file name part and uses this part (referenced as $2) with a new prefix and suffix as your replacement.

(See the example with some test cases here: regex101: build, test, and debug regex. Please test on your own!)

2 Likes

so here is a final solution I found that works jic

(<a href=")([^"']+\.mp3)(">)

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