RaZoR
January 15, 2025, 9:36am
1
Hello.
I’m using Anki to maintain several different decks with my private English words and phrases collection.
Usually, I do import my files using command line, for instance:
Command line: anki deck_2025.txt
This file starts with:
#notetype:Basic
#deck:"2025"
...
So, the deck to import cards from this file is specified in the file.
It should work according to documentation and actually it worked successfully before update to 24.11
In 24.11 this “deck” field in txt file is ignored and Anki offers to import file to the desk I’ve selected manually at previous run.
I’ve downgraded version to 24.06.3 and now it works again.
Screenshots:
24.06.3 (correct deck “2025” is automatically selected):
24.11 (wrong deck “abc” is selected…):
1 Like
abdo
January 15, 2025, 11:29am
2
Can you share a sample file? I tried this:
#notetype:Basic
#deck:"2025"
a,b
The “2025” is not being selected, so I can reproduce the issue (even in 24.06.3) (turned out the deck needs to be created first), but just want to test with your file to find the source of that “abc” deck.
1 Like
RaZoR
January 15, 2025, 11:45am
3
Surely, both decks (2025 and abc) are created beforehand.
Acutally, my decks are already filled with hundreds of cards.
Both files are in the same format:
#notetype:Basic
#deck:"abc"
a;b
#notetype:Basic
#deck:"2025"
aa;bb
anki-24.06.3 = OK
anki-24.11 = ignores deck:
field in import files
abdo
January 15, 2025, 11:55am
4
Anki 24.11 started allowing quotation marks in deck/tag names (see Do not strip quotation marks from deck/tag names by abdnh · Pull Request #3407 · ankitects/anki · GitHub ), so "abc"
and "2025"
are interpreted literally now (the quotes were silently stripped in older versions). You can fix the issue by removing the quotes from the deck field.
RaZoR
January 15, 2025, 12:28pm
5
I’ve already tried deck:2025
without quotes. The same resultant: anki ignores the field and tries to import cards to another deck.
#notetype:Basic
#deck:2025
a;b
$ anki deck_2025.txt
Wrong “abc” is selected:
abdo
January 15, 2025, 4:43pm
6
Looks like there’s a separate issue here with 2025
: Anki is actually interpreting the year as a deck ID and is defaulting to a different deck when no deck with such ID is found.
1 Like
abdo
January 15, 2025, 4:45pm
7
Sidenote: The manual is misleading on this point: Text Files - Anki Manual
1 Like
RaZoR
January 15, 2025, 7:39pm
8
I could say that manual is correct:
"deck" Deck name or id Presets the deck, if it exists.
(Note that deck
and deck column
are different keywords)
And yes! You are right - if I load deck_abc.txt, the abc
is treated as deck Name
, but in the problematic file, 2025
is treated as Id
, not Name
.
Any ideas how to deal with it without renaming my decks to ^[^0-9]*
?
It would be good to add a special condition such as toString().equals(deckName) || toInt().equals(deckId)
(pseudo code).
2 Likes
dae
January 18, 2025, 6:43am
9
@Rumo I seem to recall this has come up before - do we have an existing issue about it or stance on it? I did a quick search but couldn’t find one.
Rumo
January 19, 2025, 9:43am
10
Not aware of it.
Seems reasonable to check if a passed number is an existing deck name, but if I recall correctly, it will require some restructuring of the code.
llama
January 19, 2025, 11:24am
11
I’ve been working on a pr for this. The approach taken is to enclose numeric deck and notetype* names in single-quotes ('
), and escape other existing single-quotes present in non-numeric names with a backslash (\
)
Problem is the breakage where old clients won’t know how to handle escaped single-quotes in deck/notetype names when trying to import these new CSVs
Thoughts? Or perhaps instead of quoting and escaping, is it preferable to just assume a numeric deck name is not an id if no such deck id exists?
*this issue also applies to notetype names btw
EDIT: opened a pr
1 Like
RaZoR
January 19, 2025, 12:30pm
12
Hello.
deck:"2025"
deck:'2025'
deck:2025
find “as is” "2025"
in deck names
strip quotes, for instance: s/["']//g
find stripped 2025
in deck names
finally, find 2025
in deck IDs list
The first found result is the targeted deck.
sorata
January 19, 2025, 4:06pm
13
I think having these as subsections of “File Header” is an issue. Your link describes “deck column” and not the header that starts with #.
system
Closed
February 18, 2025, 4:07pm
14
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.