Is your feature request related to a problem? Please describe.
I have an Anki deck I’m programatically generating. My card templates are doing some interactive stuff with JavaScript. To avoid embedding a bunch of
JavaScript in the card template, I’ve chosen to store all the helper functions in a separate _Foo.js media file (the underscore prefix is necessary to get Anki to actually import the media, as suggested here: Field Replacements - Anki Manual ). This works until I make a change to this js file, at which point re-importing doesn’t actually update the js file. IIUC, it is instead creating a new filename with a hash suffix. See add_data_to_folder_uniquely. This cautious approach doesn’t help me as templates still use the original, unsuffixed js file.
This was mentioned before over in Import Media in Importer without updating Notes - #6 by Andr , but that thread is about a different feature request. I thought it would make sense to start a dedicated thread for this. My description of the issue is specific to JavaScript, but IIUC, this would also apply to soind and images as documented here: Field Replacements - Anki Manual .
Describe the solution you’d like
I’d like the ability to tell Anki to clobber existing media files rather than cautiously giving them new names.
Describe alternatives you’ve considered
As I’m generating the deck programatically, I could hash the file contents myself and generate a unique name. This would work, but I suppose would leave orphaned media in my media collection.
Closing thoughts
I don’t actually understand how Anki’s current behavior is reasonable. It seems llike it’s pretty much guaranteed to do something other than what the user wants. I understand that we are dealing with a shared namespace here (blindly clobbering files in the media directory would be dangerous) but silently renaming them (thereby producing media files that nothing references) for me violates the principle of least surprise. I’d rather the import flow call this conflict out and ask me to resolve it myself.
Am I misunderstanding things? Does Anki’s import flow actually make some effort to update references to media when it has to rename them?