Why does media check skip empty files?

If an empty file ends up in your collection, Anki won’t detect it. For example:

cd ~/.local/share/Anki2/<username>/collection.media
touch xxxxxxx.jpg
# run media check
# result: nothing detected.

Why does Anki behave this way? I think it would be more convenient if empty files were removed. I have several empty files, probably caused by ffmpeg errors when I used mpvacious to create Anki cards from movies.

1 Like

Interesting. I couldn’t find any reasoning for this in git history:

I guess simply ignoring the files was the simplest / most conservative option to implement.

2 Likes

I wouldn’t delete it either. You never know why the data wasn’t read, or why there were blocks, and so on. And if you delete it, you’ll only get complaints.

3 Likes

I wouldn’t want the .nomedia in my ankidroid collection’s media folder to be deleted by this and have my gallery cluttered

2 Likes

One could just skip the file if it’s empty and named .nomedia. The code for that should be pretty straight forward.

If you delete an empty file that is referenced in a note, you’ll next get an error message about the missing file. I recommend that an empty file not referenced be reported as unused, but not removed. If it is referenced, but it’s empty, that should also be pointed out.

1 Like

Good point. It would be nice to figure out how to report empty media files during media check, but avoid deleting them.

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