Word Count of a given field — any progress?

I want to split up a huge deck into a word/phrase and a separate sentence deck (arbitrarily, a sentence is anything with more than 5 words).

So let me get this clear: You have this huge deck, there are a lot of notes / cards in it. They have the same note type. You want to sort them by “words” vs “sentences”. Whether a note belong to the “words”-type or “sentences”-type depends on the count of words in a specific field.

Is that correct?

I have a suggestion: I am a developer, so I know my way around my text editor.

You could

  1. Go to the deck which has all these cards
  2. Click the small wheel to the right of the deck name
  3. Click Export
  4. Select “Notes in Plain Text” as the Export format
  5. Check "Include tags, uncheck Include HTML and media references
  6. Click “Export…”

What you will get is a file with the “.txt” ending. Upload this text file up here.
I will do my magic, and put a tag (let’s say “sentence”) to all notes which fall under the definition of “sentence”-type, as we discussed above.

I will then give the file back to you, and you can reexport it, thus adding the tag to all those notes.

You will need to tell me the position of the field which contains the word/sentence however. So, when opening the editor in Anki, on which position the field is (first, second, etc.).

1 Like

You can use Regular Expressions to search for note fields with a certain number of words:


This matches notes where field contains between x+1 and y+1 words (a “word” being a string of one or more non-whitespace characters delimited by whitespace or the start or end of the field string). So for your purposes, you would replace x with 4 and omit y.
This can also be further refined to ignore HTML tags or split words on an apostrophe. RegEx are really awesome. :slightly_smiling_face:


How could I forget, that Anki also has regex capabilities now. :sweat_smile: