Looking for a routine

I’m looking for a routine to automate some input. I have a spreadsheet with additions to be made to cards.
Essentially an if/then routine.
If field rank =12 then field audio = x.m4a, etc.

fields rank audio
12 x.m4a
24 d.m4a
25 q.m4a
102 z.m4a
etc. etc.

Any suggestions?
(using macbook and ipad)

It seems like you could “automate” that pretty easily in a spreadsheet.

  1. Add the additional field to your note type in Anki
  2. Export your notes (not cards) as text/CSV
  3. Use spreadsheet tools/formulas to populate that new field/column
  4. Make sure your file is properly formatted for import and update – Text Files - Anki Manual
  5. Re-import to update your notes

Thanks, it looks quite daunting to work out how to treat a deck with 11 different note types each with different number of fields, but for an assigned unique rank (by me) and a new blank.
I assume the deck must first be divided by note type and treated as a subdeck for seperate export.

You didn’t mention 11 different note types in your post. That can still work, but yes, you’ll have a much easier time if you deal with each of them separately.

You don’t need to do anything to rearrange your cards into subdecks though. You’re making changes at the note level here – exactly where each card is located is irrelevant.

Why don’t you just use ChatGPT to process the date?

Sounds interesting but would you mind expanding on this. How would it process the data on a spreadsheet?

I am a language guy, not technical, but can reasonably follow if shown some examples of what to do.
Do you have any examples of how this populating is done, or point me in the right direction?
thanks

Export the spreadsheet in CSV, TSV, or HTML format. Thoroughly explain to ChatGPT what you want it to do with the data. Ask ChatGPT to output the processed data in CSV or TSV format. Copy the output and paste it into a new text file, then save it with a .csv or .tsv extension. Import the file into Anki.

P.S. You may need to split the spreadsheet into several pieces if it’s initially too big for ChatGPT."

Probably the simplest way would be to export only a set of notes that meet a certain criteria (like rank:w:12 – rank contains “12” as a standalone word). Then your spreadsheet will have a single column you can fill with “x.m4a” – any spreadsheet app will have a way to “fill down” and populate a whole column.

Now, that obviously gets a lot more repetitive when you’re talking about 11 note types of various sizes – and however many different rank-audio pairs. If you want to keep it to a single export per note type, I’d recommend using a nested if-then formula (tons of free tutorial sites will show you how to write the formula for your spreadsheet app). You can fill your column with that formula – it will look at the rank field in that row, and display the right audio. Then you can copy the column, and paste it on top of itself as the value instead of the formula (it’s called “paste values” in Excel). Since you’re using the same if-then for all note types, you’d only have to write a solid formula once.

While writing this, I had another thought. – I don’t know how many rank-audio pairs you have, but if it’s a reasonable number, you could use Find and Replace to do this without ever leaving Anki. Narrow the set of notes in your view to just those that have a certain rank, select all, and for just that field, find blank, and populate it with the audio value you want.

I like the idea of doing it in Anki, this would allow me to work in smaller batches and not interfere with my learning.
Let’s say that I wanted to use the GUID to identify my two blank fields GUID-1 and GUID-2 and then rename the audio files GUID-1.m4a and GUID-2.m4a.
Or maybe use the Card ID or Note ID.
In either case, is there a simple way to pull any of these numbers into the blank cells and add the string (-1.m4a)

If you already have the GUID in the field, you can use Find and Replace to add the string. The example in the link I posted shows how to do that with regex (but speak up if you need more specifics). [Are you planning to use these as sound tags? Does Anki support playing m4a? I genuinely don’t know.]

But I can’t think of a way to pull from one field and append it into another field. :thinking: For that, I’d probably still export it, but it will be a much simpler process. All you’d need to manipulate is copying the GUID column to the columns for your 2 audio files, and reimport.

I didn’t quite understand what you were discussing. Therefore, if not on the subject, I apologize.
Advanced Copy Fields

The alternative is to export and then immediately import two fields. One is used as an identifier and the other is mapped to another field where it should be copied.

I don’t know that add-on, but it seems like it would work!

Your alternative idea reminded me of another one – If you Change Note Type to the same note type, you can map a single field to multiple different fields. That would work too!

Does Anki support playing m4a?
It works for me!

1 Like

Not tried it yet but I think there may be a possible solution that using Advanced Copy Fields can put unique names into the audio fields.

But to get the audio files into place I can’t see how to do it without export/ import.

That would have to be managed, it might not be as onerous as first imagined. I’ve looked at some of the spreadsheet tools and VLOOKUP looks like it’ll do the job.

Adding media is as simple as including the file name (with the correct syntax for that type of file) in a field, and adding the file to your collection.media folder. After you are done, you should run Tools > Check Media to make sure you’ve done everything correctly.

See: Text Files - Anki Manual – and Media - Anki Manual .