Hi Paul,
** OK Maybe I have sorted this by deleting everything in the XXData folder **
Oh, OK, now you will have problems by guarantee.
Unless proven otherwise of course.
I think I can state generally that with problems like too long file names, you're kind of lost. Or will lose or something. It just should never happen ...
What's a downside in a workflow like first not using Galleries and then much later using them, is that you won't notice for a long time what you should have taken precautions for - reserve some space for the additional length a Gallery path will consume.
I don't have the experience whether it would have helped you with the problems you face today, but do notice that it is not ever allowed to manipulate Gallery folders manually. So yes, it is full with redundancy. This is not in a database as such, but in the various (meta) data files you will find in the "Original Location" folders as well as in the Gallery folders themselves. This is about file names but also about the contents of them.
In other words : always use XXHighEnd for whatever you do with them (rightclick on Items in the Library Area and the various functions in there). This includes Renaming (click on the Item title = folder name).
What you currently best can do (I think) is rename all back to how you had it, reverting everything you did as exact as possible. Then hopefully all works as bad as how you started out when discovering this problem. Now use the functions for it and hope something can be done to it. But it is likely not.
A remedy could be to delete the Gallery entry (via XXHighEnd !) and check whether there's something left of it in the Gallery folder. If yes, delete that now manually. Now make thje Original Location folder sufficiently short, and obtain it in the Gallery again.
Only helpful for the future :
I face the same problem of course. But it never is a problem, because I work with Galleries from the start and 100% obtain everything in a Gallery. I thus notice right away when errors occur and solve it right there. So in the end I don't have a problem and all is clean.
Sorry to be unable of any real help !
Peter