I have a shared Anki web deck in my collection. Based on a note type in this deck, I created new note types for other decks over manage note types → Add → (select the existing note type from the imported deck). I changed fields, templates, and styling and used this note type in other decks. Due to an update of the shared deck, I imported the .apkg again and selected merge note types (because a field was added). Unfortunately, all note types based on this were merged together. Now I have only one note type with all original fields plus my self-created fields. I found this thread in the forum, where note type IDs were mentioned. Maybe the note types got merged, because they have the same note type ID? Unfortunately, I haven’t found a way to give my note types unique IDs.
@Rumo is our resident expert on the importing code; I’ll let him answer.
Notetypes always have unique IDs. However, recently imported notetypes also store an original ID recording the notetype they were derived from.
Unfortunately, there seems to be a bug causing new notetypes to inherit the original ID from the notetype they were cloned from. Now when importing with Merge notetypes enabled, all these notetype look like they have been derived from the same imported notetype and get merged.
I hope you were able to revert the merging import. You can run this script in the debug console to clear the original IDs from any notetypes you have created locally (i.e. not imported from someone else). But make sure to backup your collection first!
from PyQt6.QtWidgets import *
dialog = QDialog()
layout = QVBoxLayout()
dialog.setLayout(layout)
notetypes = [(nt, QCheckBox(nt["name"])) for nt in mw.col.models.all() if nt.get("originalId", False)]
if notetypes:
label = "Check notetypes you created locally to clear their original IDs."
else:
label = "No notetypes with original IDs found."
layout.addWidget(QLabel(label))
for nt, box in notetypes:
layout.addWidget(box)
dialog.exec()
for nt, box in notetypes:
if box.isChecked():
del nt["originalId"]
nt.update()
Thank you for the explanation! I tried it again after executing your code and unfortunately, the note types still got merged. Nevertheless, I got it done by exporting the decks with my own notetypes and importing them again after the shared deck was updated.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.