This is done to prevent issues when moving to case-insensitive filesystems: Importer overwrites existing media files with different letter cases · Issue #4433 · ankitects/anki · GitHub
The quickest fix would be to modify ames to convert the filename to lowercase before saving, but more generally, the tool is using AnkiConnect’s storeMediaFile method to save the media file but failing to check the response to get back the normalized filename (Anki also normalizes the name to remove problematic characters).