Images not displaying after 2.1.65 update

I’m using the desktop app on a Apple Silicon Mac. After updating to 2.1.65, a large number of images on my cards are not displaying. These seem to be cards that have html escape characters in the filename, like “%27foo%27%2C_1913_bar_01.jpg”. After renaming the files to remove the escape characters, like “foo_1913_bar_01.jpg”, and updating the image src in the card, the image once again displays.

Is there some way to get these paths to display again? Or failing that, is there some way to mass update them? There are very many so doing them all one-by-one is prohibitive.

How were those files added? Anki would not write files into the media folder with such names when pasting/using the paperclip icon IIRC. You can probably automate the repair process by using some third-party tool to batch-rename files, and then using Anki’s find&replace feature to apply the same change to your fields.

Bulk renaming of the files should be possible with macOS‘ rename functionality in this case (select multiple files in Finder, right click → rename, replace).

How were those files added?

The images were probably copied via a shell script and the notes were added with File > Import, from csv files. This is how I create most of my notes.

I’ve done a little more investigation and it turns out that the files will display if I rename the files with the escaped character. So for example, if I rename file%20with%20spaces.png to file with spaces.png, the file will display in Anki, regardless of whether I rename the file within Anki itself. So it seems that the change that broke my cards was Anki interpreting local pathnames as URL-escaped.

If anyone else has this issue I believe I have fixed it by renaming all the files in my media folder to their url-decoded versions. Specifically, I used a urldecode function found on stack overflow (I tried to link to the answer but links are not allowed in this forum it seems):

function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

Then, from inside my Anki media folder, I ran

for f in * ; do mv "$f" "$(urldecode "$f")" ; done

(Obviously, back up the folder before trying this.)

With this approach it is not necessary to modify the Anki notes themselves.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.