Add predefined strings to existing fields across multiple cards


I have about 2k cards with sound clips on them and have been looking for the best way to get the clip filename onto the card and into clipboard (from where it can be used by another app).

One way (credit u/BlackBeans) is to change the fields from [sound:xyz.mp3] to just xyz.mp3, and then have [sound:{{field}}] in the template. This works well as long as the template is simple, but weird things can happen if you have several clips on the same template and/or {{field}} happens to be empty. So far I have been using this method, but I think I may change my mind and if so I don’t want to put the [sound: ] back in manually on 2k cards.

Another way is just to have an extra field containing the filename… but again I don’t want to add the version without [sound: ] manually on 2k cards. In some cases this would have to be done for more than one field per card.


What is the easiest way to insert predefined strings at the beginning and end of an existing field, for a large number of cards? I asked a similar Q previously and someone suggested writing an add-on, but that is totally new territory for me so I’m hoping there’s another way.

What is the easiest way to copy the contents of one field to another, new field, again for a large number of cards?

Sometimes I feel as though it would be easiest to export the lot, make the changes in Excel, then reimport, but that way I guess I would lose the metadata, scheduling etc (or would I?)

Regular expressions (RegEx).

You can define a capturing group with parentheses and use it in the replacement with $i, where i is the index of the group within your regular expression.

For your use case, select the notes in the Browser, go to Find & Replace, select the field and “Treat input as regular expression”, then insert the following:


Find: (.*)

  • translates to “Match a string of any length (as long as possible) with any characters (except newlines) and store it.”
    • to include newlines, you could use ([\S\s]*).

Replace: [sound:$1]

  • references the stored group with $i