Add script to clean up datadirs

It tries to detect the version of the client last used on the datadir, and only removes files that are not in use by that version or any later versions.