I was able to get the script to work using filenames similar to yours by this adding 2 lines after $file = $_:
This just catches the '=' and ',' in the first half, and replaces those with '\=' and '\,' respectively. I had a similar issue as yours in the past and this is how I addressed it. You may also run into '.' and '..' erroring out, but the other files should move. I would also add rename ... or die syntax as was suggested by Aaron.
Hope this helps.