Batch Editing [Official Support Thread]

This is the official support thread for the Batch Editing add-on.

If you have a general support-related question, please feel free to post it here.

If you run into a bug and are familiar with GitHub, please consider filing a bug report, instead. The entry form on GitHub takes care of a lot of the troubleshooting groundwork, so it really makes it a lot easier for me to reproduce bugs and fix them.

New release:

Version 0.4.0 – 2023-10-26

Added

  • Added support for Anki 23.10 (thanks to @khonkhortisan for the report)

Fixed

  • Fixed image button icon not working (thanks to @dollajas for the report)
  • Fixed image format changing from PNG to JPG when pasting images (thanks to @AH349 for the report)

Changed

  • Modernized and rewrote large parts of the codebase
  • Fixed deprecated use of note.model (thanks to @Arthur-Milchior, #17)

You can view all past releases here.

What are the differences to the built in search and replace feature? Is it a different user interface or does it offer additional functionality?

I think it would be helpful to have that information in the description.

The information is in the add-on page. There’s a description and screenshots!

It offers some convenience features that makes it easy to add and replace field content without needing to whip out regular expressions. But yeah, as @suiyuan mentioned, there’s more info in the add-on description on AnkiWeb. I might add more of an intro to these support threads in the future, but currently short on time.

Hey there,

How does the “add after” and “add before” functionality work? I also keep getting the message “target undo op not found”, even when I try to use the replace function

Hi, i think this add on has stopped working. Currently on 25.02.4 on windows. Thanks.

Hi,

I tried the add-on out but it doesn’t show on my Anki. Is it because it doesn’t support the newest version of anki?

Hey, I really appreciate your add-on — it works great and has been very useful.
I wanted to suggest a small modification: allowing users to select multiple local media files at once when using the attach action in Batch Edit.

I tested this only locally on my own setup (I did not distribute anything), and it worked well for my workflow.

Why this helps

The current single-file picker makes bulk image workflows slow (e.g., adding anatomy/histology/radiology image sets to existing notes). Multi-select would make batch editing much faster.

Minimal code-level idea

In dialog.py, replace single-file selection with QFileDialog.getOpenFileNames() and loop through selected files:

from aqt.qt import QFileDialog
import os

def choose_files(self):
    key = "Images (*.jpg *.jpeg *.png *.webp)"
    paths, _ = QFileDialog.getOpenFileNames(self, "Add Images", "", key)
    if not paths:
        return []
    # optional: stable order
    return sorted(paths, key=lambda p: os.path.basename(p).lower())

def insert_media(self):
    media_files = self.choose_files()
    if not media_files:
        return
    if not (editor := self._browser.editor):
        return

    html_fragments = []
    for media_path in media_files:
        filename = self._collection.media.add_file(media_path)
        html = editor.fnameToLink(filename)
        html = self._browser.editor._addMedia(media_path, canDelete=True)
        if hasattr(self._collection.media, "escape_images"):
            html = self._collection.media.escape_images(html, unescape=True)
        else:
            html = self._collection.media.escapeImages(html, unescape=True)
        html_fragments.append(html)

    current = self.text_edit.toPlainText()
    new = "\n".join([*current.strip("\n").split("\n"), *html_fragments]) if current else "\n".join(html_fragments)
    self.text_edit.setPlainText(new)

Thanks again for maintaining this add-on — this small change would be a big quality-of-life improvement for heavy batch-media workflows.