I was trying to use the plugin Advanced Copy Fields - AnkiWeb Advanced Copy Fields to edit my collection, but it was not changing my notes after I updated to the latest commit on the main branch.
Then, I wrote my own script to edit my notes like the following, but neither my script was changing my notes on my collection. Do I need to flush something else now?
for name, did in mw.col.db.execute(f"select name, id from decks"):
print(f"Deck name {name}, did {did}.")
# AllMyDecksRootLanguagesJapaneseKana (Katakana/Hiragana)
source_deck_did = 1582942327697
target_field = "BottomButtons"
target_note_type_name = "Katakana to Hiragana"
value_to_add = \
"""
<script>
function tryinput(event) {
if( $('#try').val() )
{
if( $('#try').val() != $('#get').val() ) {
$('#try').css({'background-color': 'red'});
}
else {
$('#try').css({'background-color': '#0f0'});
}
}
else {
$('#try').css({'background-color': 'white'});
}
}
$('#try').on('compositionstart', tryinput);
$('#try').on('compositionend', tryinput);
$('#try').on('compositionupdate', tryinput);
$('#try').on('change', tryinput);
$('#try').on('keyup', tryinput);
$('#try').on('keydown', tryinput);
</script>
"""
for nid, in mw.col.db.execute(f"select id from notes"):
note = mw.col.getNote(nid)
note_type = note.note_type()
if note_type["name"] == target_note_type_name:
print(f"Changing note type {note.id}...")
cards = note.cards()
first_card = cards[0]
deck_id = first_card.did
if deck_id == source_deck_did:
print(f"Changing deck {note.id}...")
note[target_field] = value_to_add
note.flush()