Anki Media Deduplicator

AnkiWeb addon 490461948

Finds byte-for-byte identical media files, rewrites note references to one canonical filename, and safely moves redundant copies to Anki's media trash after a read-only dry run.
AI-generated summary; may contain mistakes.

duplicatesbackup-maintenance

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
0 (👍 0 · 👎 0)
Updated
2026-09-04
Anki versions
26.08.1~
License
AGPL-3.0 (from the GitHub repository)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, JSON
Description language
zh

Maintenance

active

  • Last update or commit: 2026-09-04 (58 days before the snapshot).
  • Test files: 12.
  • Commits in the last year: 15.
  • Issues: 0 open, 0 closed.
  • Pull requests: 0 open, 0 merged.

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
25.09.426.08.1+2026-09-04
History across monthly snapshots

Loading…

Similar addons

Deck duplication has 1 fork →

Clones a deck and its subdecks in place, retaining media references but not tags, and deletes duplicate notes whose fields are completely identical.

duplicatesdeck-management

50 votes 84% approval 👍 47 · 👎 3 Anki 2.1.66~ Updated 2022-06-11
Inline CSS Cleanup

Extracts and deduplicates inline CSS from selected note fields, moves it to a shared media file, then inserts import links—optionally handling repeated inline styles, base64 images and Yomitan media references—to shrink collections.

sync-integrationnote-managementformattingbackup-maintenance

2 votes 34% approval 👍 2 · 👎 0 ⭐ 7 Anki 23.12~ Updated 2026-09-14

Description

Safely consolidate byte-for-byte identical files in Anki's collection.media folder.

English

What it does

Anki Media Deduplicator finds media files with exactly identical content, rewrites note references to one canonical filename, and moves redundant copies to Anki's trash through the official media API. It is designed especially for collections affected by AnkiDroid's historical temporary-file naming behavior.

Safety

  • Every scan is a read-only Dry Run; nothing changes until you explicitly click Apply.
  • Files must match by size, extension, full SHA-256, and a final chunked byte-for-byte comparison.
  • Different extensions are never merged.
  • Media referenced by notetype templates/CSS, filenames beginning with _, and latex- files are protected.
  • File existence, size, modification time, and content are checked again before Apply.
  • Canonical media is created first, note references are updated second, and redundant files are trashed last.
  • All note updates and media deletions use Anki's official APIs so changes can sync correctly.
  • The algorithm is O(N + total candidate media bytes); it never compares every file with every other file.

Usage

  1. Open Tools → Anki Media Deduplicator....
  2. Click Scan Media.
  3. Review the summary and duplicate groups table.
  4. Click Apply Deduplication and confirm the operation.
  5. Sync normally after completion.

Important: Applying moves redundant files to Anki's media trash first; this alone does not free disk space. To actually reclaim the space, open Tools → Check Media and permanently delete the files from the media trash.

This add-on removes exact duplicate media. It does not replace Anki's Check Media feature for finding unused or missing files.

简体中文

功能说明

Anki 媒体去重会查找内容逐字节完全相同的媒体文件,将笔记中的引用统一改写为一个规范文件名,然后通过 Anki 官方媒体 API 把多余副本移入回收站。本插件主要用于处理受 AnkiDroid 历史临时文件命名行为影响的媒体库。

安全机制

  • 每次扫描都是只读的 Dry Run;只有明确点击“应用去重”后才会修改数据。
  • 文件必须依次通过大小、扩展名、完整 SHA-256 和最终分块逐字节比较,才会被认定为重复文件。
  • 不同扩展名的文件永远不会合并。
  • 卡片模板或 CSS 静态引用的媒体、以 _ 开头的文件及 latex- 文件都会受到保护。
  • 应用前会重新检查文件是否存在,以及大小、修改时间和内容是否发生变化。
  • 操作顺序始终是:先确保规范媒体存在,再改写笔记引用,最后才处理多余文件。
  • 笔记更新和媒体删除均使用 Anki 官方 API,确保后续同步能够正确传播变更。
  • 算法复杂度为 O(N + 候选媒体总字节数),不会对所有文件进行两两比较。

使用方法

  1. 打开 工具 → Anki 媒体去重...。
  2. 点击 扫描媒体。
  3. 检查汇总信息和重复文件组表格。
  4. 点击 应用去重,并在确认窗口中核对修改数量。
  5. 完成后正常同步 Anki。

重要: 应用去重只会先将多余媒体移入 Anki 回收站,不会立即释放磁盘空间。要真正释放空间,请打开 工具 → 检查媒体,在其中实际删除回收站里的媒体文件。

本插件处理的是内容完全相同的重复媒体,并不替代 Anki 自带的 检查媒体;后者用于查找未使用或缺失的媒体文件。

Compatibility / 兼容性

  • Primary target / 主要目标:Anki Desktop 26.08.1
  • Compatibility floor / 最低兼容版本:Anki Desktop 25.09.4
  • Interface languages / 界面语言:English, 简体中文

Source code, documentation and issue tracker / 源码、文档与问题反馈: https://github.com/HuangAntimony/anki-media-deduplicator

License / 许可证: AGPL-3.0-or-later

README

Anki Media Deduplicator

An Anki Desktop add-on that safely removes media files whose contents are exactly identical.

It is especially useful for collections affected by AnkiDroid imports that saved the same audio or image repeatedly under different filenames.

This add-on removes duplicate media. It does not replace Anki's Check Media tool, which finds unused or missing files.

Features

  • Read-only scan and Dry Run before anything is changed.
  • Only merges files that are byte-for-byte identical and have the same extension.
  • Shows affected notes, references to rewrite, and reclaimable space before applying.
  • Updates note references before moving redundant files to Anki's trash.
  • Protects static template/CSS media, _ files, and latex- files.
  • Uses Anki's official collection and media APIs so changes sync correctly.
  • English and Simplified Chinese interface.

Installation

AnkiWeb (recommended)

  1. In Anki Desktop, open Tools → Add-ons.
  2. Click Get Add-ons....
  3. Enter add-on code 490461948.
  4. Restart Anki.

Open the AnkiWeb add-on page

GitHub release

Download the .ankiaddon file from the latest GitHub release, then open it with Anki or choose Tools → Add-ons → Install from file....

Usage

  1. Open Tools → Anki Media Deduplicator....
  2. Click Scan Media.
  3. Review the Dry Run summary and duplicate groups.
  4. Click Apply Deduplication and check the confirmation carefully.
  5. Sync Anki normally after completion.

Applying moves redundant files to Anki's media trash; this alone does not free disk space. To actually reclaim the space, open Tools → Check Media and permanently delete the files from the media trash.

The add-on does not run automatically and does not start a sync.

Safety

Files are verified again when you apply a scan result. If a file has changed or disappeared, its duplicate group is skipped. A canonical file is always made available and note references are migrated before redundant copies are trashed.

As with any tool that modifies a collection, make sure your collection has a current backup before applying changes. Files moved to Anki's media trash remain on disk until they are permanently deleted in Check Media.

Limitations

  • Exact duplicates only; similar images or transcoded audio are not detected.
  • Files with different extensions are not merged.
  • Unused-media cleanup is outside this add-on's scope.
  • Apply cannot be cancelled after confirmation.

Compatibility

  • Anki Desktop 26.08.1 is the primary target.
  • Anki Desktop 25.09.4 and newer are supported.
  • Older deprecated Anki APIs are not supported.

Development

python3 -m venv .venv
.venv/bin/python -m pip install pytest ruff
.venv/bin/python -m pytest tests benchmarks
.venv/bin/ruff check .

The test suite includes a synthetic 50,000-file workload.

License

GNU Affero General Public License v3.0 or later.