Okay, I've attached a script I wrote and tested in my viperalley.com website which cleaned up about 60 duplicate filenames.
I make no warrenties for this script and it's use; the code seems proper and it worked on my site for the 60 dupes I had. I suggest you check it yourself and backup your photos table before you run it (and even your data directory).
There is error checking built-in - but again, you should review it for yourself and be sure you understand what it is doing before running it.
Please do not PM me for support or sales questions. Thank you for your understanding.