In addition to the above advice...
this...
After much fiddling I decided to delete them all and start again. Current status is that many files still carry the wrong name and many are a mixture of unrelated tracks. I'm on MC 19. What have I done wrong? Should I just delete the program and reload it.
suggests to me that the embedded tags have been updated with the erroneous data. To correct this, once you have restored your backup, and are happy that the library looks to be OK, you would look to select all tracks the "right click > Library Tools > Update tags from library" which should correct any errors in the file tags.
It will only update files that actually need it, but could still take some time.
Also,
Your registration is stored in the system registry and will be picked up by the program if you remove and reinstall it. In this case though, I don't believe that is necessary. Follow the advice offered above and you should be OK.
-marko